You need to sign in to do that
Don't have an account?
Varun Sharma 177
Error Parsing JSON in REST API Web Service
Hi All,
I was given this sample JSON by our partner and I am trying to write a REST Web service to ingest it but I can't seem to get it to work. I am testing it in Workbench and am getting this error:
Unexpected parameter encountered during deserialization: orderNumber at [line:2, column:17
Here is the Apex Class:
And here is the sample JSON:
I was given this sample JSON by our partner and I am trying to write a REST Web service to ingest it but I can't seem to get it to work. I am testing it in Workbench and am getting this error:
Unexpected parameter encountered during deserialization: orderNumber at [line:2, column:17
Here is the Apex Class:
@RestResource(urlMapping='/DPS_Response/') global with sharing class DPSResposnse { global class AllParties { global String partyId; global String decision; } @HttpPost global static String updateDPSData (String orderNumber, AllParties[] parties) { return 'test'; } }
And here is the sample JSON:
{ "orderNumber":"000042289", "parties": [ { "partyId": "12345", "decision": "D" }, { "partyId": "09876", "decision": "P" } ] }
While you testing this service in workbench or postman. You have to mention Apex Method arguments properly in request body as same as in Apex.
In apex method first argument is orderNumber so you have to mention the same format in JSON also. If any letter was in caps then you have to use the same caps letter in JSON. Spelling also have to be same. So check you are using the correct property name in JSON for orderNumber.
orderNumber ==> correct one.
ordernumber ==> Wrong one. n is in small . and you will get the below error.
message: Unexpected parameter encountered during deserialization: ordernumber at [line:2, column:20]
errorCode: JSON_PARSER_ERROR
i tested your webservice it's working fine.
Thanks,
Maharajan.C
All Answers
Pg In Ahmedabad - Boys And Girls (http://www.notshout.com/p/pg-in-ahmedabad.html)
Latest Love Shayari in Hindi, True Love Status, Best Love Sms Whatsapp status (http://www.notshout.com/2020/03/latest-love-shayari-in-hindi-true-love.html)
Best Love Shayari in Hindi Whatsapp status (http://www.notshout.com/2020/03/best-love-shayari-in-hindi-notshout.html)
Love Shayari in Hindi, True Love Status, Best Love Sms Whatsapp status (http://www.notshout.com/2020/03/love-shayari-in-hindi-true-love-status.html)
Bewafa Shayari In Hindi (http://www.notshout.com/2020/03/bewafa-shayari-in-hindi.html)
Paying Guest In Ahmedabad - Boys And Girls (http://www.staywellahmedabad.com/pg-in-ahmedabad.php)
Attitude Status (https://www.notshout.com/2020/03/attitude-status_15.html)
Attitude Shayari In Hindi For Love (https://www.notshout.com/2020/03/attitude-shayari-in-hindi-for-love.html)
Attitude Shayari (https://www.notshout.com/2020/03/attitude-shayari.html)
Attitude Status (https://www.notshout.com/2020/03/attitude-status_15.html)
Best Shayari in Attitude Shayari (https://www.notshout.com/2020/03/best-shayari-in-attitude-shayari.html)
Hindi Shayari On Positive Attitude (https://www.notshout.com/2020/03/hindi-shayari-on-positive-attitude.html)
Khatarnak Attitude Shayari (https://www.notshout.com/2020/03/khatarnak-attitude-shayari.html)
Hindi Shayari On Positive Attitude Boy (https://www.notshout.com/2020/03/hindi-shayari-on-positive-attitude-boy.html)
Hindi Shayari On Positive Attitude Girl (https://www.notshout.com/2020/03/hindi-shayari-on-positive-attitude-girl.html)
Khatarnak Attitude Status (https://www.notshout.com/2020/03/khatarnak-attitude-status.html)
Royal Attitude Status (https://www.notshout.com/2020/03/royal-attitude-status.html)
Royal Attitude Status In Hindi (https://www.notshout.com/2020/03/royal-attitude-status-in-hindi.html)
While you testing this service in workbench or postman. You have to mention Apex Method arguments properly in request body as same as in Apex.
In apex method first argument is orderNumber so you have to mention the same format in JSON also. If any letter was in caps then you have to use the same caps letter in JSON. Spelling also have to be same. So check you are using the correct property name in JSON for orderNumber.
orderNumber ==> correct one.
ordernumber ==> Wrong one. n is in small . and you will get the below error.
message: Unexpected parameter encountered during deserialization: ordernumber at [line:2, column:20]
errorCode: JSON_PARSER_ERROR
i tested your webservice it's working fine.
Thanks,
Maharajan.C