Hello Everyone,
I am new to the outsystems platform but I am loving it so far I have just run into one snag. I cannot debug an error I have been getting when trying to consume a REST API for a vehicle inventory system i'm designing. Whenever i use the decode button I get this error at the top of the screen
Failed to parse response of the method 'PostDecode' of the 'Dataonesoftware' REST API: Parsing '': Unexpected character encountered while parsing value: A. Path '', line 0, position 0.
I have tried to look for every solution I could on the we and I cannot get anything to work. If someone could help point me in the right direction that would be awesome. I'm not sure if i'm just using the REST API incorrectly or if there is a step I'm missing.
ServiceCenter Error Information
Request
client_id=[ID]&authorization_code=[AuthCode]+&decoder_query={ "decoder_settings" : { "display" : "full", "version" : "7.2.0", "styles" : "on", "style_data_packs" : { "basic_data" : "on", "pricing" : "off", "engines" : "off", "transmissions" : "off", "standard_specifications" : "off", "standard_generic_equipment" : "off", "oem_options" : "off", "optional_generic_equipment" : "off", "colors" : "off", "warranties" : "off", "fuel_efficiency" : "off", "green_scores" : "off", "crash_test" : "off", "awards" : "off" }, "common_data" : "off", "common_data_packs" : { "basic_data" : "on", "pricing" : "off", "engines" : "on", "transmissions" : "on", "standard_specifications" : "on", "standard_generic_equipment" : "on", "oem_options" : "on", "optional_generic_equipment" : "on", "colors" : "on", "warranties" : "on", "fuel_efficiency" : "on", "green_scores" : "on", "crash_test" : "on", "awards" : "on" } }, "query_requests" : { "Request-Sample" : { "vin" : "", "year" : "", "make" : "", "model" : "", "trim" : "", "model_number" : "", "package_code" : "", "drive_type" : "", "vehicle_type" : "", "body_type" : "", "body_subtype" : "", "doors" : "", "bedlength" : "", "wheelbase" : "", "msrp" : "", "invoice_price" : "", "engine" : { "description" : "", "block_type" : "", "cylinders" : "", "displacement" : "", "fuel_type" : "" }, "transmission" : { "description" : "", "trans_type" : "", "trans_speeds" : "" }, "optional_equipment_codes" : "", "installed_equipment_descriptions" : "", "interior_color" : { "description" : "", "color_code" : "" }, "exterior_color" : { "description" : "", "color_code" : "" } } }}
Thanks!
-Bryan
Hi Bryan,
Did you check the response by increasing the logging level of the REST API? If not please do so, so you can check the response and see if it's actually JSON.
Hey Kilian,
First thank you for your response! I did increase the logging level of the REST API but it still only returns what is at the beginning of my original post
Hi Brian,
You're showing the Error Log. You must look in the Integration Log in order to see what's sent.
Whoops sorry about that here is the integration detail
I'm wondering if it has something to do with how I am passing my input parameters, like I said im very new at this and I'm only guessing on a lot of this stuff haha
The most important part, the HTTP Trace is missing. This shows the exact received HTTP content, including the faulty JSON. In order to see it, you need to increase the logging level, like I described above.
After increasing the logging level i found that it isn't sending anything from the application as a request so i started playing with it and got it to pass my authorization headers but still not any of the formatted request. Im at a loss right now and cant figure out how to make this API work. any hep will be appreciated.
Here is the information that is out into the test fields. I'm just having trouble translating this to really work for me
POST /webservices/vindecoder/decode HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: api.dataonesoftware.com
User-Agent:OutSystemsPlatform
client_id=46&authorization_code=c43fdc7+&decoder_query={
"decoder_settings" : {
"display" : "full",
"version" : "7.2.0",
"styles" : "on",
"style_data_packs" : {
"basic_data" : "on",
"pricing" : "off",
"engines" : "off",
"transmissions" : "off",
"standard_specifications" : "off",
"standard_generic_equipment" : "off",
"oem_options" : "off",
"optional_generic_equipment" : "off",
"colors" : "off",
"warranties" : "off",
"fuel_efficiency" : "off",
"green_scores" : "off",
"crash_test" : "off",
"awards" : "off"
},
"common_data" : "off",
"common_data_packs" : {
"engines" : "on",
"transmissions" : "on",
"standard_specifications" : "on",
"standard_generic_equipment" : "on",
"oem_options" : "on",
"optional_generic_equipment" : "on",
"colors" : "on",
"warranties" : "on",
"fuel_efficiency" : "on",
"green_scores" : "on",
"crash_test" : "on",
"awards" : "on"
........
Response
HTTP/1.1 200 OK
Content-Type: application/json
Connection: keep-alive
Vary: Accept-Encoding
Content-Length: 1245
Date: Wed, 26 Sep 2018 15:53:35 GMT
Server: Apache
{
"decoder_messages": {
"service_provider": "DataOne Software, Inc.",
"decoder_version": "7.2.0",
"decoder_errors": [] },
"query_responses": {
"Request-Sample": {
"transaction_id": "TEA7479CC9B7B5A1EC781F6FD0AEA23AF5573049A", "query_error": {
"error_code": "", "error_message": "" },
"us_market_data": {
"us_styles": [ {
"name": "4dr Sedan 5A",
"vehicle_id": "100668206",
......
Maybe I just need to do more training, thank gosh for the community haha. If anyone can help or point me in the right direction that would be awesome if not maybe some resources on where to find training for this system as I am only 2 weeks in and I love it I just need to obtain more information about how to do things with this platform
Can you share an OML that shows what you've got so far? It's difficult troubleshooting without some code.
Yes I can! Here it is, I'm realizing the issue lies in passing the clientid, authcode and vin to get the response. Im just not sure how to format these to get them to pass all this information over. Thanks again for all your help!
I'm seeing nothing particularly strange, but of course I don't have the API description (can't find it on the website), so I'm not sure why you get an authentication error.
The reason why OutSystems gives that "Failed to parse" error is that the API sends a 200 OK, but doesn't provide any data (instead, the string "Authentication failed."). This is clearly a bug on the part of the API, but since it's external, not something you can do much about.
The error is happening because of two things. First, you need to add the client id and the correct authorization codes. Second, the decoder_query must be present. The absence of it causes the authorization error at the same.
I just used the example you gave previously (the client id, the authorization code and the query, and passed everything to the call and the error was gone. (a new one appeared, in the looping after the method is called).
Cheers.
Thank you so much Eduardo! That did it I have gotten the authorization to pass through however now i'm stuck on formatting the JSON to be passed. When I look at the error in detail it looks like the JSON request is not getting properly formatted I'm currently searching for a solution but any help is always appreciated!.
POST https://api.dataonesoftware.com/webservices/vindecoder/decode HTTP/1.1User-Agent: OutSystemsPlatformContent-Type: application/x-www-form-urlencodedHost: api.dataonesoftware.comContent-Length: 1555client_id=XXXXX&authorization_code=XXXXXXXX&decoder_query=%7bdecoder_settings%3a%7bdisplay%3afull%2cversion%3a7.2.0%2cstyles%3aon%2c%0d%0astyle_data_packs%3a%7b%0d%0abasic_data%3aon%2c%0d%0a%7d%2c%0d%0acommon_data%3aoff%2c%0d%0acommon_data_packs%3a%7b%0d%0abasic_data%3aon%2c%0d%0apricing%3aoff%2c%0d%0aengines%3aon%2c%0d%0atransmissions%3aon%2c%0d%0astandard_specifications%3aon%2c%0d%0astandard_generic_equipment%3aon%2c%0d%0aoem_options%3aon%2c%0d%0aoptional_generic_equipment%3aon%2c%0d%0acolors%3aon%2c%0d%0awarranties%3aon%2c%0d%0afuel_efficiency%3aon%2c%0d%0agreen_scores%3aon%2c%0d%0acrash_test%3aon%2c%0d%0aawards%3aon%0d%0a%7d%0d%0a%7d%2c%0d%0aquery_requests%3a%7b%0d%0aRequest-Sample%3a%7b%0d%0avin%3a%2c%0d%0ayear%3a%2c%0d%0amake%3a%2c%0d%0amodel%3a%2c%0d%0atrim%3a%2c%0d%0amodel_number%3a%2c%0d%0apackage_code%3a%2c%0d%0adrive_type%3a%2c%0d%0avehicle_type%3a%2c%0d%0abody_type%3a%2c%0d%0abody_subtype%3a%2c%0d%0adoors%3a%2c%0d%0abedlength%3a%2c%0d%0awheelbase%3a%2c%0d%0amsrp%3a%2c%0d%0ainvoice_price%3a%2c%0d%0aengine%3a%7b%0d%0adescription%3a%2c%0d%0ablock_type%3a%2c%0d%0acylinders%3a%2c%0d%0adisplacement%3a%2c%0d%0afuel_type%3a%0d%0a%7d%2c%0d%0atransmission%3a%7b%0d%0adescription%3a%2c%0d%0atrans_type%3a%2c%0d%0atrans_speeds%3a%0d%0a%7d%2c%0d%0aoptional_equipment_codes%3a%2c%0d%0ainstalled_equipment_descriptions%3a%2c%0d%0ainterior_color%3a%7b%0d%0adescription%3a%2c%0d%0acolor_code%3a%0d%0a%7d%2c%0d%0aexterior_color%3a%7b%0d%0adescription%3a%2c%0d%0acolor_code%3a%0d%0a%7d%0d%0a%7d%0d%0a%7d%0d%0a%7dHTTP/1.1 200 OKConnection: keep-aliveVary: Accept-EncodingContent-Length: 358Content-Type: application/jsonDate: Mon, 01 Oct 2018 20:31:01 GMTServer: Apache { "decoder_messages" : { "service_provider" : "DataOne Software, Inc.", "decoder_version" : "7.2.0", "decoder_errors" : [ { "error_code" : "IQ", "error_message" : "Invalid query. Query must be properly formatted JSON." } ] }, "query_responses" : { } }
Thanks so much guys, this community is awesome!!!!!!
Well, the Platform URL encodes everything that's passed as x-www-form-urlencoded. I'm not sure why (whether this is the way it should be), but apparently, the consumed REST service doesn't like it. What you could do is replace all those fugly %xx by the corresponding actual characters in the OnBeforeRequest, but I'm not sure whether it's not something else you're not doing correctly. Without the actual REST API description, I find it hard to tell.
Here is all the documentation I have for the API, I'm wondering if I have to build a List like in this post https://www.outsystems.com/forums/discussion/32940/how-to-use-json-arrays/
See attached
HI Bryan,
Can you please check your response structure datatype, I faced same problem one attribute of response structure was integer but value supplied was more than integer range and getting same error I changed datatype from integer to long integer then my problem resolved.
Regards
-SK-
@Shashi: Please read before you respond. The problem at hand is about what's sent, not about what's received!
@Bryan: Did you create the "decoder_query" part by hand? Because it is indeed not valid JSON. When decoding it, it looks like this:
{decoder_settings:{display:full,version:7.2.0,styles:on, style_data_packs:{ basic_data:on, },
While JSON would look like this:
{ "decoder_settings": { "display":"full", "version":"7.2.0", "styles":"on", "style_data_packs":{ "basic_data":"on", },
So all the double quotes are missing (as your own test request shows above)!
You should create the JSON by creating the correct Structures in Service Studio, then use the JSON Serialize Statement to serialize it and add it as parameter to the REST call.
Did you check my answer above? Did you get it working?
Unfortunately I have not yet figured out how to pass all this information, I have created a decoder_request structure by hand with all the required information for the request and am passing that through JSONserialize but first I cannot get my request format to be JSON because it requires a structure or list. When I have the server action set to pass the JSONserialize there is not structure or list its just a regular input variable. I'm not getting anything with the HTTP trace just the headers and {} which to me means the data isn't getting passed. I have a meeting with a solutions architect on Monday so I'm hoping to learn more from him/her. I'm just limited on knowledge with this system but very ambitious haha. If you have any more insight it's always appreciated.