Autodesk Forge - Versions GET Downloads returns 400 "Request cannot be handled" - autodesk-forge

Making 2 and/or 3 legged auth request to Version/GetDownloads returns 400 when VersionId is valid and existing.
When trying to make an http call to a version's download endpoint (https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-version_id-downloads-GET/), the response returns:
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"id": "a306d506-e374-4734-a68e-86c998fc7a5a",
"status": "400",
"code": "BAD_INPUT",
"title": "One or more input values in the request were bad",
"detail": "Request cannot be handled."
}
]
}
This would be ok if the Version Id didn't exist for the corresponding project, but requesting the version's download formats (https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-version_id-downloadFormats-GET/) returns a 200 response,
despite the version not having any download format:
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/{PROJECT_ID}/versions/{URN_VERSION_ID}/downloadFormats"
}
},
"data": {
"type": "downloadFormats",
"id": {URN_VERSION_ID},
"attributes": {
"formats": []
}
}
}
The file I am testing with is a pdf uploaded to BIM360 via the UI. I would have expected to get at least a 200 response on both endpoints. Also, I quite not understand why the downloadFormats endpoint does not return any format.

Related

Amadeus flights API error: carrier code is a 2 or 3 alphanum except YY and YYY

I am using the following SDK to search for and purchase flights via Amadeus:
https://github.com/autotune/amadeus/pull/1/files
This was a previously abandoned project I have decided to take on and make work. As part of that project I am trying to purchase a ticket in the sandbox environment and getting the following error:
{
"errors": [
{
"code": 477,
"title": "INVALID FORMAT",
"detail": "carrier code is a 2 or 3 alphanum except YY and YYY",
"source": {
"pointer": "/data/flightOffers[0]/itineraries[1]/segments[0]/operating/carrierCode",
"example": "AF"
},
"status": 400
}
]
}
Here is the json data being sent:
{
"type": "flight-order",
"travelers": [
{
"id": "1",
"dateOfBirth": "1990-02-15",
"name": {
"firstName": "Foo",
"lastName": "Bar"
},
"gender": "MALE",
"contact": {
"emailAddress": "foo#bar.com",
"phones": [
{
"deviceType": "MOBILE",
"countryCallingCode": "33",
"number": "5555555555"
}
]
}
}
],
"ticketingAgreement": {
"option": "DELAY_TO_CANCEL",
"delay": "6D"
},
"remarks": {},
"operating": {
"carrierCode": "UA"
}
}
Any help appreciated!
The error suggests that the sent payload is invalid. I'd advice you use a tool like Curl or Postman to verify you're using the right API documentation, before debugging actual code.
After further reading your PR and checking the API reference at :
https://developers.amadeus.com/self-service/category/air/api-doc/flight-create-orders/api-reference
I think you need to confirm that the Carrier code being passed is available in the segments under:
flightOffers > itineraries > segments
Although the API reference doesn't have operating > carrierCode like you used in the data sent, my guess after seeing the API error response you shared is that they are performing a check against the flight offers passed.
I suggest you check the results gotten when you call the flightOffers and also add it to the payload sent to the sandbox.

Why can't I submit a record to Zoho Sales Order API?

I'm trying to insert a record using the Zoho API, and I keep receiving a cryptic INVALID_DATA error message.
I've tried using their sample code which, of course, produces another error. And the sample code they provide for running in Postman also produces an error.
Their docs are lacking and inconsistent, and nobody is getting back to me on their message boards, and I'm getting desperate as I need to have this done today. Can anyone see what I'm doing wrong?
This is what I'm submitting via Postman
{
"data": [
{
"Owner": {
"id": "3938209039489388001"
},
"Contact_Name": {
"id": "398129039938498309"
},
"Subject": "Test",
"Product_Details": [
{
"product": {
"id": "1234567"
},
"quantity": 1
}
]
}
]
}
This is the error response
{
"data": [
{
"code": "INVALID_DATA",
"details": {
"api_name": "product",
"index": 0,
"parent_api_name": "Product_Details"
},
"message": "invalid data",
"status": "error"
}
]
}
The solution was to POST a product first, then grab that product ID and insert it under Product_Details. This is not documented, so I assumed the product would be created automatically, which it wasn't.

Can i Use a normal HTTPS rest service for request / response for alexa, not using the alexa SDK

I am creating a normal HTTPS web-service to interact with Alexa. I am able to receive the request in the service and when i am returning response in the same structure as Alexa is expecting! i am getting an error. I am unable to get what's the problem.. the JSON body and Headers are set as per the standards. I am not using lambda, but trying to interact with Alexa with a normal HTTPS service.
Header:
HTTP/1.1 200 ok
content-type = application/json;charset=UTF-8
//Response JSON which is not been identified by alexa
{
"version": "1.0",
"sessionAttribute": {},
"response": {
"outputSpeech": {
"ssml": "<speak> Donut and Coffeee Aussie Style</speak>",
"type": "SSML"
},
"card": {
"content": "to the world",
"title": "Ava"
},
"speechletResponse": {
"outputSpeech": {
"ssml": "<speak>Donut and Coffee Aussie Style</speak>"
},
"card": {
"content": "to the world",
"title": "Ava"
},
"shouldEndSession": "true"
}
}
}
I found what was the problem with my response codes. The fields sessionAttributes speechletResponse are optional fields. The actual field which was missing in above JSON response is the type key value in card response. Even thought the card object itself is optional. If you are using it then you have to have a field called as type in the same. working json response below. Hope this helps the people who are trying to invade the alexa space.
{
"version": "1.0",
"sessionAttribute": {},
"response": {
"outputSpeech": {
"ssml": "<speak> Donut and Coffeee Aussie Style</speak>",
"type": "SSML"
},
"card": {
"type":"Standard",
"content": "to the world",
"title": "Ava"
},
"speechletResponse": {
"outputSpeech": {
"ssml": "<speak>Donut and Coffee Aussie Style</speak>"
},
"card": {
"content": "to the world",
"title": "Ava"
},
"shouldEndSession": "true"
}
}
}

Not getting json response in SOAPUI when a post request successfully executed in postive scenario but in negative it returns

I am new to SoapUI, I ran a post request in it for creating a user. It returned success code 201 (Same as Postman), which should be, but it is not showing any data under JSON tab in Response window. Where it should show some data as the request is returning data in JSON format in Postman.
The response returned in the Postman is:
{
"id": 107,
"creationTime": "2017-06-23T12:55:13.870+0000",
"lastUpdateTime": "2017-06-23T12:55:13.870+0000",
"username": "Testuserr",
"name": null,
"firstname": null,
"type": null,
"avatar": null,
"mobile": null,
"office": null,
"email": null,
"enabled": false,
"_links": {
"self": {
"href": "http://server/...../user/107"
},
"consultantUser": {
"href": "http://server/...../user/107"
},
"roles": {
"href": "http://server/...../user/107/roles"
},
"regularRole": {
"href": "http://server/...../user/107/regularRole"
},
"userSkills": {
"href": "http://server/...../user/107/userSkills"
},
"experiences": {
"href": "http://server/...../user/107/experiences"
},
"educations": {
"href": "http://server/...../user/107/educations"
},
"assignments": {
"href": "http://server/...../user/107/assignments"
},
"certificats": {
"href": "http://server/...../user/107/certificats"
},
"organisation": {
"href": "http://server/...../user/107/organisation"
},
"sections": {
"href": "http://server/...../user/107/sections"
}
}
}
Where in SoapUI it shows nothing.
But if am running the same request 2nd time it shows
{
"cause": {
"cause": {
"cause": null,
"message": "Duplicate entry 'TestName20181' for key UK_r43af9ap4edm43mmtq01oddj6'"
},
"message": "could not execute statement"
}
Which is same as Postman, and should be. Then what is the problem with first time?
Help me if there was anything, I was missing during execution ... thanks...
I just figured out the difference, the content-type/media-type is blank for 201/200.Postman intelligently detects the content-type as json and displays.
I just walked to Developer desk to confirm if root cause is right and yes it is,
For 400 (negative tests):
In the exception handler class, they return with media type as
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity(errors, responseHeaders, HttpStatus.BAD_REQUEST);
But for 201/200 (positive tests):
They dont set contentType, its global or default setting as per spring boot framework.
Solution#1: So DEV has to explicitly set the contentType as JSON for SOAP UI to display the json body so that we can write test scripts in it or else you will only see null response in SOAPUI though it is 200/201.
Solution#2: In your SOAP UI request, add a parameter in 'Header' as Accept = application/json. This will solve your problem without dev support.
Thanks to https://community.smartbear.com/t5/SoapUI-Pro/Change-the-reponse-from-content-type-text-html-to-text-json/td-p/39628
Screenshot

Generate POSTMAN in webpage with JSON or something

I have a restAPI code from a programmer from JNE, company stands for delivery service.
They say that this API can be run in POSTMAN (Google Chrome Application)
It works fine in the POSTMAN, where in this application I just need to insert the request URL (which I have got from the JNE company) and two header of keys and values as follow;
KEY VALUE
----------------------------------------------
username mycompany
api key 4534645756864234523424
The method for this is POST and when I posted it, it gives me the results as how expected.
My problem now is, how can I run this code in my page, so that I don't need to run this in postman.
I am just this day going to learn JSON if anybody can help me out with this.
[UPDATE QUESTION 1]
{
"version":1,
"collections":
[
{
"id":"c8b12431-8586-cbdd-aef7-056ec177509a",
"name":"asdasdadasdasdasd",
"timestamp":1415593872130,
"requests":
[
{
"collectionId":"c8b12431-8586-cbdd-aef7-056ec177509a",
"id":"d1b2ed66-781d-d02e-c4eb-0416dd3e07a1",
"name":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jak",
"description":"",
"url":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jak",
"method":"POST",
"headers":"username: mycompany\napi_key:089a12ffb8cd5009bdfa4ba5bdb9ee26\n",
"data":
[
{
"key":"username",
"value":"mycompany",
"type":"text"
},
{
"key":"api_key",
"value":"dsfsdfsdfs98d98sdfsdf9898dsfs",
"type":"text"
}
],
"dataMode":"params",
"timestamp":0,
"responses":[],
"version":2
}
]
}
],
"environments":[],
"headerPresets":[],
"globals":[]
}
From the update question above; my first question is: ]
In what format I have to save this file: JSON? or WHAT?
Should I save this file in one file with my webpage? or Can I save it as external file?
From the code above, I get the result as follow:
{
"detail": [
{
"code": "CGK10000",
"label": "JAKARTA"
},
{
"code": "CGK10100",
"label": "JAKARTA BARAT"
},
{
"code": "CGK10300",
"label": "JAKARTA PUSAT"
},
{
"code": "CGK10200",
"label": "JAKARTA SELATAN"
},
{
"code": "CGK10500",
"label": "JAKARTA TIMUR"
},
{
"code": "CGK10400",
"label": "JAKARTA UTARA"
}
]
}
If you have a look to the "label" it is generated from the key of the last string in the: "name":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jak",
The result of the label from the last string of jak, is what I want to insert in a dropdown html tag, in where the user will choose that (the name of the location).
[Update with complete code]
POST /tracing/mycompany/origin/key/jak HTTP/1.1
Host: api.jne.co.id:8889
Content-Type: application/json
username: mycompany
api_key: 089a12ffb8cd5009bdfa4ba5bdb9ee26
{
"version":1,
"collections":
[
{
"id":"c8b12431-8586-cbdd-aef7-056ec177509a",
"name":"asdasdadasdasdasd",
"timestamp":1415593872130,
"requests":
[
{
"collectionId":"c8b12431-8586-cbdd-aef7-056ec177509a",
"id":"d1b2ed66-781d-d02e-c4eb-0416dd3e07a1",
"name":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jakarta",
"description":"",
"url":"http://api.jne.co.id:8889/tracing/mycompany/origin/key/jakarta",
"method":"POST",
"headers":"username: mycompany\napi_key:089a12ffb8cd5009bdfa4ba5bdb9ee26\n",
"data":
[
{
"key":"username",
"value":"mycompany",
"type":"text"
},
{
"key":"api_key",
"value":"089a12ffb8cd5009bdfa4ba5bdb9ee26",
"type":"text"
}
],
"dataMode":"params",
"timestamp":0,
"responses":[],
"version":2
}
]
}
],
"environments":[],
"headerPresets":[],
"globals":[]
}
I have saved this file as jne.json and jne.html but the browser just show the full code insted show the result as how the postman does. I think there are many things I am missing here.
The POST request would look something like the following
POST /tracing/mycompany/origin/key/jak HTTP/1.1
Host: api.jne.co.id:8889
Content-Type: application/json
username: mycompany
api_key: 089a12ffb8cd5009bdfa4ba5bdb9ee26
{
... your JSON ...
}
You can save JSON with the .json file extension. If your request is always the same you can save this file with your webpage, but normally an HTTP request is constructed before sending (that means you normally send different requests).
To fill the dropdown list you just have to parse the JSON response.