Hi,
I am doing an HttpPost to send data to LoopBack and get the response. I am getting an error as below from LoopBack :
HTTP/1.1 422 Unprocessable Entity [X-Powered-By: Express, Vary: Origin, Accept-Encoding, Access-Control-Allow-Credentials: true, Content-Type: application/json; charset=utf-8, Content-Length: 1528, Date: Thu, 18 Dec 2014 18:13:45 GMT, Connection: keep-alive]
So, what I did in java is created a json from a java object , when I used this JSON in loopback api explorer, the data was inserted and gave me response 200, but doing from Java, I am getting this error. Does anyone have an idea about this.
Java code is as below
JSONObject json = new JSONObject(jsonString);
StringEntity stringEntity = null;
try {
stringEntity = new StringEntity(json.toString());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(POST_CLAIM_URL);
post.setEntity(stringEntity);
HttpResponse httpResponse = null;
try {
httpResponse = client.execute(post);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
I had make sure , I am not adding a duplicate entry.
Regards,
Varun
422 is a validation error, the details are returned in the response body. Please post the full error response here.
Hi @vajaiswal14
Is this issue still persisting?
Thanks.
Hi @vajaiswal14
The issue is closed for now. If you are still running into problems, feel free to leave a comment and I will reopen the issue.
Thanks.
I am seeing this error. Whats the fix?
I am seeing this error. Whats the fix?
Send valid model data in your HTTP request body. Check the body of the 422 response to learn why the data provided in the request is not valid.
I have an object which has property "weight" as number,
Now when I pass from angular it is "weight": "50" and in loopback 4 it requires "weight": 50 ,
how do i achieve this i do not want to do anything in angular. Kindly suggest I am tired of doing this since past 2 days.
Most helpful comment
422 is a validation error, the details are returned in the response body. Please post the full error response here.