You need to sign in to do that
Don't have an account?
snejana
Problems with creating new object via REST
Hi all, please, help.
I need to use REST for creating new portal user
I use apigee.com.
I create class and GET works well, but I have problems with POST.
@RestResource(urlMapping='/WSPortalUser/*') global with sharing class WSPortalUser{ @HttpGet global static User doGet(){ RestRequest req = RestContext.request; RestResponse res = RestContext.response; String userId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); User result = [SELECT Id, Name FROM User WHERE Id = :userId]; return result; } @HttpPost global static String doPost(String name){ return name; } }
GET:
https://na14.salesforce.com/services/apexrest/WSPortalUser/005i0000000M2lB HTTP/1.1 200 OK Date: Thu, 13 Jun 2013 02:44:33 GMT Content-Length: 144 Content-Type: application/json;charset=UTF-8 { "attributes": { "type": "User", "url": "/services/data/v24.0/sobjects/User/005i0000000M2lBAAS" }, "Name": "Admin", "Id": "005i0000000M2lBAAS" }
POST:
https://na14.salesforce.com/services/apexrest/WSPortalUser?name=TestName HTTP/1.1 400 Bad Request Date: Thu, 13 Jun 2013 02:53:18 GMT Content-Length: 118 Content-Type: application/json;charset=UTF-8 [ { "message": "The HTTP entity body is required, but this request has no entity body.", "errorCode": "JSON_PARSER_ERROR" } ]
What do I do wrong? Please, any ideas.
I found the solve my problem:
1. Wrong url, should be
2. I must set into header
3. I must set into body the following text
Problem occurred because of the absence in the apigee.com the 'apexrest' API method.
So, I should click on the 'POST Create Object' first of all and then the 'Body' tab was appeared.
Sorry for bother.
All Answers
I found the solve my problem:
1. Wrong url, should be
2. I must set into header
3. I must set into body the following text
Problem occurred because of the absence in the apigee.com the 'apexrest' API method.
So, I should click on the 'POST Create Object' first of all and then the 'Body' tab was appeared.
Sorry for bother.
is this work for cross platform.???
for that. server site require any webservice to handle the request.
Regards
yogeshwer
"message": "Unexpected parameter encountered during deserialization: name at [line:3, column:12]",
"errorCode": "JSON_PARSER_ERROR"
} plz i got this error plz help me the that line