function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bakul.patelbakul.patel 

Different behaviors of same REST service

 I have following code in a REST service exposed through Force.com site
 
Case c = new Case (AccountId = '0019E000002pKMCQA2', description='est mgsg', Origin='Phone', Status='New');
insert c;

When I call this REST service from hurl.it, it works fine and creates case.
When I call this same REST service from different program, it fails. I get error Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, invalid parameter value: []

Pleaes note that all the field values are hard coded, so there is no chance of 2 clients providing different data to REST service.

Any help highly appreciated.
Best Answer chosen by bakul.patel
bakul.patelbakul.patel
After doing number of trial and error for hours, I solved the problem.
The problem was with HTTP request parameter named id. When in simulation, I removed that paramter, it worked just fine, and when I put that parameter back in, it would give error. But my HTTP request are coming from 3rd party, and I have no control to avoid id parameter in request. So, I updated my REST service code to remove that paramter from map first, and then do rest of the logic execution.

It seems to be a bug in Salesforce platform though.

All Answers

bakul.patelbakul.patel
After doing number of trial and error for hours, I solved the problem.
The problem was with HTTP request parameter named id. When in simulation, I removed that paramter, it worked just fine, and when I put that parameter back in, it would give error. But my HTTP request are coming from 3rd party, and I have no control to avoid id parameter in request. So, I updated my REST service code to remove that paramter from map first, and then do rest of the logic execution.

It seems to be a bug in Salesforce platform though.
This was selected as the best answer
Marcilio SouzaMarcilio Souza
Hi,

Probably your external program doesn't set all the required parameters to call a salesforce WS.

Se this example:
http://www.albinsblog.com/2014/07/calling-salesforce-rest-based.html#.WEr9QdIrLIU

Sorry, I don't find the oficial salesforce documentation.

Regrets,
Marcilio
bakul.patelbakul.patel
Thanks for the reply Marcilio. My REST service is exposed through site, so it does not need authentication.
Also, I am nto getting any data from request, I am inserting record with hard coded values. And that's where all the confusion is.

I also realized that when I send request from hurl.it, it works sometime and does not work other times. The behavior is totally random. Though when I take off id parameter from hurl.it request then it works always. And sometimes, even when I keep id parameter, it does works.

So, totally baffling whats going on.