You need to sign in to do that
Don't have an account?
Sri549
REST API Response Issue
Hi Guys,
I am facing an issue when sending a request to using REST API & the response which i am seeing in the Response status is "Unprocessable Entity" & code is 422.
Could you please help me in solving this.
Thanks!
Srinivas
I am facing an issue when sending a request to using REST API & the response which i am seeing in the Response status is "Unprocessable Entity" & code is 422.
Could you please help me in solving this.
Thanks!
Srinivas
Check if the format is correct like request.setHeader('Content-Type', 'application/json); in request header. Also make sure you have missed any required fields that need to be sent in body.
Thanks,
HttpRequest req = new HttpRequest();
req.setEndpoint(this.bitty.Endpoint__c + '/apply');
req.setMethod('POST');
req.setTimeout(60000);
req.setHeader('Authorization', 'Bitty ' + this.accessToken);
req.setHeader('Content-Type', 'application/json');
req.setBody(JSON.serialize(new Request(this.opportunityId)));
return req;
I didn't miss any required fields in the body,
Could you please look in to this.
Greetings!
This error is occurring due to your header attribute Content-Type.
Please check the value of this attribute.
If your request has a body of JSON, then the value of the attribute should be 'application/json'.
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi
Thanks for quick reply,
If you see my header on top i added req.setHeader('Content-Type', 'application/json');
Endpoint=https://dev.bittyadvance.com/api/submit, Method=POST
I am getting my body in the normal format which is " Request body is--
{"zip":"10120",
"state":"New York",
"start_date":"2014",
"owner":{"zip":10120,
"state":"New York",
"last_name":"test",
"first_name":"test",
"email":"nikhilg113114@gmail.com",
"dob":"1991",
"city":"New York",
"cell_phone":"(551) 232-0965",
"address2":"112 W 34th St\r\nNew York , NY",
"address":"112 W 34th St\r\nNew York , NY"},
"legal_name":"test 6 by 19",
"leadId":"0061h00000HsAprAAF",
"ein":"90-0000000",
"city":"New York",
"apikey":"dwVXv0S!QcmPJoU2pkWf!nHTEhbOus^D$%679K^&gRxF3rZLyeYjt%GA&NM5$zBCaql48",
"address2":"112 W 34th St\r\nNew York , NY",
"address":"112 W 34th St\r\nNew York , NY"}.
Could you please let me know, where the issue lies here. I am bit confused.
Thanks!
Srinivas