I'm using Newman in order to execute a POSTMAN collection but I always have the
error "connect ETIMEDOUT". Using just POSTMAN it works fine, but not with NEWMAN.
The testing is quite simple, create a content on the server
https://jsonblob.com/api
I'm following the tutorial
http://blog.getpostman.com/2014/04/17/how-to-write-automated-tests-for-apis-with-postman-part-2/
Thanks you very much in advance. I put below the collection and the enviroment file.
This is the collection:
{
"id": "a6a6b2fe-db11-4c57-9144-6b3324174f18",
"name": "Newman",
"values": [
{
"key": "url",
"value": "https://jsonblob.com",
"enabled": true,
"type": "text"
},
{
"key": "deviceMapping",
"value": "{\n \"content\": \"My first blog post :)\"\n}",
"enabled": true,
"type": "text"
},
{
"key": "blogLink",
"value": "https://jsonblob.com/api/jsonBlob/b7f2ce87-4c8e-11e8-917b-9137e61d314b",
"enabled": true,
"type": "text"
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2018-04-30T16:13:07.630Z",
"_postman_exported_using": "Postman/6.0.10"
}
This is the enviroment file:
{
"id": "a6a6b2fe-db11-4c57-9144-6b3324174f18",
"name": "Newman",
"values": [
{
"key": "url",
"value": "https://jsonblob.com",
"enabled": true,
"type": "text"
},
{
"key": "deviceMapping",
"value": "{\n \"content\": \"My first blog post :)\"\n}",
"enabled": true,
"type": "text"
},
{
"key": "blogLink",
"value": "https://jsonblob.com/api/jsonBlob/b7f2ce87-4c8e-11e8-917b-9137e61d314b",
"enabled": true,
"type": "text"
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2018-04-30T16:13:07.630Z",
"_postman_exported_using": "Postman/6.0.10"
}
Fixed: It was a proxy matter. I wrote these two commands in the cmd console:
set HTTPS_proxy=myuser:mypassword#ipoftheproxy:portoftheproxy
set HTTP_proxy=myuser:mypassword#ipoftheproxy:portoftheproxy
It was a proxy issue for me, I added my organization specific proxy in Postman settings and it worked.
Fixed by change the proxy protocol
For Mac User
Go to Settings -> Network -> Advanced -> Proxies
Tick "Auto Proxy Discovery"
Click "Ok"
Click "Apply"
Restart Postman
Another way:
Go to Postman Settings
Set SSL certificate verification to off
Let me know if you found any issue
Related
I'm building a simple slack bot and I am playing with the checkboxes element.
When I return the following from my API in a JSON response to a slash-command I get an error failed with the error "invalid_blocks", however, when I put this in the block-kit-builder it works perfectly (including "sending to slack" button)
Any ideas why this is failing when I run my slash command - and is it possible to see more detailed error messages from slack?
{
"blocks": [
{
"elements": [
{
"style": "primary",
"text": {
"emoji": true,
"text": "Create new TODO list",
"type": "plain_text"
},
"type": "button",
"value": "value"
},
{
"style": "primary",
"text": {
"emoji": true,
"text": "Help",
"type": "plain_text"
},
"type": "button",
"value": "value"
}
],
"type": "actions"
},
{
"text": {
"text": "Today",
"type": "mrkdwn"
},
"type": "section"
},
{
"elements": [
{
"initial_options": [
{
"text": {
"text": "Get Into the garden",
"type": "mrkdwn"
},
"value": "foo"
}
],
"options": [
{
"text": {
"text": "Get Into the garden",
"type": "mrkdwn"
},
"value": "foo"
}
],
"type": "checkboxes"
},
{
"style": "primary",
"text": {
"emoji": true,
"text": "Add new Task",
"type": "plain_text"
},
"type": "button",
"value": "value"
}
],
"type": "actions"
}
],
"type": "home"
}
I am using the Slack Web API. I was getting the similar error. After a lot of looking around, here's how I solved it.
import json
blocks = [{...}]
payload = {
"blocks": json.dumps(blocks)
}
You will then send this payload.
in the api, the "blocks" parameter need to be string type. Did you convert it to string or you use it as a JSON ?
https://api.slack.com/methods/chat.postMessage
In the Block Kit Builder, the data is a JSON with a blocks key.
In the Slack API, the blocks param is only the list of JSON objects.
blocks = [
{
"text": {
"text": "Its the list of your blocks",
"type": "mrkdwn"
},
"type": "section"
}
]
text = 'Alternative data in text'
client.chat_postMessage(channel=channel_id, blocks=blocks, text=text)
Another cause of this problem seems to be too many blocks being returned. I can't find any documentation about this whatsoever, but personal experience seems to indicate about 20 blocks is the maximum.
An alternative is to return fewer blocks, with paging actions -- paging works well with the "replace" message so that the content being paged through does not result in many separate messages.
It appears that not all valid elements in block kit tool can be posted as a message, despite the fact that message preview works fine in the Block Tool.
In my case, the code failed when I included an input block and passed when i removed it. The input block was generated by the Block Kit tool.
{
"type": "input",
"element": {
"type": "plain_text_input",
"action_id": "plain_text_input-action"
},
"label": {
"type": "plain_text",
"text": "Feedback",
"emoji": true
}
}
The error was
{'ok': False, 'error': 'invalid_blocks'}
Also, although the documentation for python says you need to urlEncode the JSON-based array, there is no example, and it is incorrect. https://api.slack.com/methods/chat.postMessage
You can see on line 29 in the SDK test code below that blocks= takes a regular list of dicts not a string.
https://github.com/slackapi/python-slack-sdk/blob/c9dc6aa0907a72c16cf36aa15e7e80031a9fdce2/integration_tests/samples/basic_usage/sending_a_message.py
swagger 2.0.
.netcore 2.1
swashbuckle as in the image.
I have this attribute on an api endpoint:
[SwaggerResponse(statusCode: 200, type: typeof(List<Cat>), description: "successful operation")]
When I run the API and navigate to https://localhost:44394/swagger/v1/swagger.json the json is there but the SwaggerResponse seems to be being ignored.
This is an example of what I receive:
"/api/data/cats": {
"get": {
"tags": [
"CatApi"
],
"operationId": "GetCatsById",
"consumes": [],
"produces": [],
"parameters": [
{
"name": "catIds",
"in": "query",
"required": true,
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"collectionFormat": "multi",
"uniqueItems": false
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
You can see that the response just show a 200 and I'm not exactly sure where it's getting that description from - as you can see in the attribute it should be successful operation and my XML comment is <response code="200">successful operation</response>.
I'm very confused. How can I get Swashbuckle it use the SwaggerResponse attribute when it generates the json?
More info:
If I use [ProducesResponseType(statusCode: 200, type: typeof(List<Cat>))] then I get what I want:
"/api/data/cats": {
"get": {
"tags": [
"CatsApi"
],
"operationId": "GetCatsById",
"consumes": [],
"produces": [
"text/plain",
"application/json",
"text/json"
],
"parameters": [
{
"name": "catIds",
"in": "query",
"required": true,
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"collectionFormat": "multi",
"uniqueItems": false
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"uniqueItems": false,
"type": "array",
"items": {
"$ref": "#/definitions/Cat"
}
}
}
}
}
},
You can see the additional data in the produces field and the schema in the responses field.
I could change to use ProducesResponseType everywhere but it isn't a standard field as far as Swagger is concerned - if I ever regenerate the code from the swagger file then I'll have to always make these changes so I'd like to get it working with SwaggerResponse.
Step 1: Double check if your are missing the Swagger Decorator Attributes, follow this below and replace the attributes with your specific Types / MyModel
Since you didn't put up your actual code, to see how it works, use the default samples for e.g. you can Install my Swashbuckle.Examples NuGet package. Decorate your methods with the new SwaggerResponseExample attributes below and you will see it work just fine!
// These attributes will help with your nested objects
[SwaggerResponse(HttpStatusCode.OK, Type=typeof(IEnumerable<Country>))]
[SwaggerResponseExample(HttpStatusCode.OK, typeof(CountryExamples))]
[SwaggerResponse(HttpStatusCode.BadRequest, Type = typeof(IEnumerable<ErrorResource>))]
public async Task<HttpResponseMessage> Get(string lang)
Ste 2: Also ensure you have it configured like so
configuration
.EnableSwagger(c =>
{
c.OperationFilter<ExamplesOperationFilter>();
})
.EnableSwaggerUi();
Also make sure you have the right using for the annotations. I searched and searched because the SwaggerResponse were missing and i couldn't get my head behind it.
I somehow managed to use Nswag Annotations, but needed Swashbucke using:
using Swashbuckle.AspNetCore.Annotations;
I think it came because as i didn't have a nuget for SwaggerResponse installed and the first suggestion for a nuget package that has this type was nswag.
I am developing a solution for a product and trying to implement C2C connection. I am in stuck with linking SmartThings with my backend via OAuth.
I get request
{
"lifecycle": "CONFIGURATION",
"executionId": "41d224ba-7de3-77ac-fe87-a56fa6f325c3",
"locale": "en",
"version": "0.1.0",
"client": {
"os": "ios",
"version": "1.6.17",
"language": "uk"
},
"configurationData": {
"installedAppId": "7393625f-64d5-42cb-a52f-7935a677c4bb",
"phase": "PAGE",
"pageId": "linkPage",
"previousPageId": "",
"config": {}
},
"settings": {}
}
And return response, that is rendered in SmartThings App:
{
"configurationData": {
"page": {
"pageId": "linkPage",
"nextPageId": "",
"previousPageId": "",
"complete": true,
"name": "Account Linking",
"sections": [ {
"name": "Please, link SmartThings to your XXXXXX account",
"settings": [ {
"id": "linkAccount",
"name": "Link Account",
"type": "OAUTH",
"required": true,
"urlTemplate": "https://xxxxxx.auth.us-east-2.amazoncognito.com/login?response_type=code&client_id=20kucf9dcg5ju9deqeppugqft1&state=7393625f-64d5-42cb-a52f-7935a677c4bb&redirect_uri=https%3A%2F%2Fapi.smartthings.com%2Foauth%2Fcallback"
} ]
} ]
}
}
}
Authentication passes successfully and returns code to callback like that:
https://api.smartthings.com/oauth/callback?code=9dfea1ca-54e8-47e8-ba90-24f20068ad2b&state=7393625f-64d5-42cb-a52f-7935a677c4bb
But the callback returns HTTP 401.
I've read this topic https://community.smartthings.com/t/cloud-to-cloud-oauth-rest-api/118902 and did not find a solution. No more helpful info I could found on the Web.
Has anybody implemented this with success?
The Support is awful - no response for several days.. From my previous Support contacting experience - they can respond after several weeks...
Thank you!
This is a bug of iOS SmartThings application, Android works fine.
https://community.smartthings.com/t/cant-implement-oauth-for-cloud-to-cloud/143258/7
I'm evaluating atlassian-connect-express and just created an app
boilerplate with "atlassian-connect new", and then deployed it via ngrok
to my Jira dev account.
That works fine, but when I try to use the file "credentials.json" with
my account data, the plug starts with the error message:
Failed to register with host https‍://michael%40...:[My
password]#connect-ace.atlassian.net (401)
Add-on not registered; no compatible hosts detected
I get a similar message when I go to the url connect-ace.atlassian.net
Here my atlassian-connect.json
{
"key": "my-add-on",
"name": "Ping Pong",
"description": "My very first add-on",
"vendor": {
"name": "Angry Nerds",
"url": "https://www.atlassian.com/angrynerds"
},
"baseUrl": "https://xxxxxxx.ngrok.io",
"links": {
"self": "https://xxxxxxxx.ngrok.io/atlassian-connect.json",
"homepage": "https://xxxxxxx.ngrok.io/atlassian-connect.json"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed"
},
"scopes": [
"READ"
],
"modules": {
"generalPages": [
{
"key": "hello-world-page-jira",
"location": "system.top.navigation.bar",
"name": {
"value": "Hello World"
},
"url": "/hello-world",
"conditions": [{
"condition": "user_is_logged_in"
}]
},
{
"key": "hello-world-page-confluence",
"location": "system.header/left",
"name": {
"value": "Hello World"
},
"url": "/hello-world",
"conditions": [{
"condition": "user_is_logged_in"
}]
}
]
}
}
and my credatials.json
{
"hosts": {
"connect-ace.atlassian.net": {
"product": "jira",
"username": "michael#---",
"password": "---password---"
}
}
}
How can I get my dev account working with connect-ace?
Two things to check:
1 - Check the if the credentials.json has correct values. host url should start with https://. Password is the api token generated from here.
{
"hosts": {
"https://<your atlassian site name>.atlassian.net": {
"product": "jira",
"username": "<jira user name>",
"password": "<Token created from https://id.atlassian.com/manage/api-tokens>"
}
}
}
2- Enable development mode at Settings -> Apps -> Manage Apps -> Settings. (This is required if the app is not published in marketplace)
This error is a default from atlas-connect
Print error image
In atlasssian-connect.json
replace this :
"lifecycle": {
"installed": "/installed"
},
for this:
"lifecycle": {
"installed": "installed"
},
Have you tried spawning your own cloud instance and testing it there? If not yet, try creating one here. Once successfully registered, in your credentials.json, change "connect-ace" with your baseUrl/sitename and with the right credentials, it should automatically install it for you.
I have an internal app that uses a webhook listener and some scripting to manipulate the input data. I'm posting this to it:
curl -X POST -d '{
"assignment_id": 12345,
"updated_custom_fields": [{
"name": "RNVIDAYEBB",
"value": "updated!"
},
{
"name": "QUFTXSIBYA",
"value": "and me too"
}
],
"custom_fields": [{
"id": 981,
"name": "RDEXDPVKRD",
"fields": [
{
"id": 4096,
"name": "RNVIDAYEBB",
"default": "EDJEAJICYW",
"required": true,
"value": "Blah"
},
{
"id": 4097,
"name": "QUFTXSIBYA",
"default": "",
"required": true,
"value": ""
}]
}]
}' "https://hooks.zapier.com/hooks/catch/......"
My script is as follows:
update_custom_fields_by_name_pre_write: function(bundle) {
var updatedFields = _.map(bundle.request.data.custom_fields, function(group) {
return _.map(group.fields, function(field) {
return _.extend(field, _.findWhere(bundle.request.data.updated_custom_fields, { name: field.name} ));
});
});
bundle.request.data = updatedFields;
return bundle.request;
}
I know that the merging logic is good, but it appears that the custom_fields and updated_custom_fields arrays are not present in the bundle.request.data object. Anyone know how to get access to them in the script?
It seems like you should be using update_custom_fields_by_name_catch_hook to capture the incoming static webhook data (instead of _pre_write). If you use that, you can capture the data within bundle.cleaned_request.custom_fields and bundle.cleaned_request.updated_custom_fields.