Thanks to Simon, I have now gone a step ahead after changing the URI to /services/data/v21.0/sobjects/user.
However now I get a HTTP status 400. I need to admit that I am not setting all the "Required" fields of a User object. But my question here is, doesn't Sales Force / RESTful API's send back an appropriate error message pin pointing the exact problem?
Simon, pardon my ignorance on Sales Force / RESTful API's, but I didn't get what you meant by http body?
To provide you the context, I am trying to alter the Getting Started with the Force.com REST API sample to create a User instead of an Account. Hence I use the same HttpClient library as suggested. If you meant the variable "responseBody" (of type byte[]) of PostMethod object, then it is null in my case.
send a POST to /services/data/v21.0/sobjects/user
My initial POST was to /services/data/v20.0/sobjects/User/
I started getting an IOException with the following stack trace :-
StringRequestEntity.writeRequest(OutputStream) line: 150
PostMethod(EntityEnclosingMethod).writeRequestBody(HttpState, HttpConnection) line: 495
PostMethod(HttpMethodBase).writeRequest(HttpState, HttpConnection) line: 1973
PostMethod(HttpMethodBase).execute(HttpState, HttpConnection) line: 993
HttpMethodDirector.executeWithRetry(HttpMethod) line: 397
HttpMethodDirector.executeMethod(HttpMethod) line: 170
HttpClient.executeMethod(HostConfiguration, HttpMethod, HttpState) line: 396
HttpClient.executeMethod(HttpMethod) line: 324
DemoREST.createUser(String, String, String, PrintWriter) line: 172
DemoREST.doGet(HttpServletRequest, HttpServletResponse) line: 325
DemoREST(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 617
DemoREST(HttpServlet).service(ServletRequest, ServletResponse) line: 717
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 290
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206
StandardWrapperValve.invoke(Request, Response) line: 233
StandardContextValve.invoke(Request, Response) line: 191
StandardHostValve.invoke(Request, Response) line: 127
ErrorReportValve.invoke(Request, Response) line: 102
StandardEngineValve.invoke(Request, Response) line: 109
CoyoteAdapter.service(Request, Response) line: 291
Http11Processor.process(Socket) line: 859
Http11Protocol$Http11ConnectionHandler.process(Socket) line: 602
JIoEndpoint$Worker.run() line: 489
Thread.run() line: 680
Thanks to Simon, I have now gone a step ahead after changing the URI to /services/data/v21.0/sobjects/user.
However now I get a HTTP status 400. I need to admit that I am not setting all the "Required" fields of a User object. But my question here is, doesn't Sales Force / RESTful API's send back an appropriate error message pin pointing the exact problem?
Regards,
Guru
Yes they do, look at the http body you got back with that 400 response.
Simon, pardon my ignorance on Sales Force / RESTful API's, but I didn't get what you meant by http body?
To provide you the context, I am trying to alter the Getting Started with the Force.com REST API sample to create a User instead of an Account. Hence I use the same HttpClient library as suggested. If you meant the variable "responseBody" (of type byte[]) of PostMethod object, then it is null in my case.