Error 400 while POST request with JSON
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2015 01:48 AM
Hi all,
I am trying to send a JSON data through RESTMessage POST using the below steps:
1) I have set ${content} in the content body.
2) I have set http header 'Content-Type' as 'application/json'
3) I have added 'content' in the variable substitutions
In my script include I am using exactly the same code as shown in 'preview script usage' of that post request. Below is the code.
try {
var r = new sn_ws.RESTMessageV2('<Rest module name>', 'post');
r.setStringParameter('content', '{"assetBook":"abc","assetId":"222","assetNumber":"333","assetType":"xyz","description":"test","massAdditionId":"131"}');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
But I am getting a 400 http status response when i run it. I tried using the 'test' link in the post method page with the same data as test value and it works perfectly with 200 status. I am not able to figure out what the issue is as iam using exactly the same code given for preview script.
Please help.
Siddhartha
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 07:49 AM
Hi Rajendra ,
I am getting HTTP status as 400 even when I click on Test Related link for my POST REST Message , please suggest .
I tried and troubleshooted all . I checked the HTTP headers , tried to delete some of the variable substitutions. Nothing is working . Also we are using MID server.
Please let me know if you require any further information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 07:50 AM
Hi Rajendra,
Please see REST Message response code: 400 and help on this. This is the thread I opened for my issue.