Skip to main content
11 votes

How to give date and time values in request body using postman

Use Pre-request script tab to save the date into a variable: var current_timestamp = new Date(); postman.setEnvironmentVariable("current_timestamp", current_timestamp.toISOString()); and then use it ...
Lucie Lavickova's user avatar
10 votes
Accepted

Can we insert multiple records in sObject using REST API post method without using apex class in workbench or postman

Create Multiple Records using rest API Documentation While the SObject Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same type. In a ...
Ratan Paul's user avatar
  • 22.7k
9 votes
Accepted

Not able to post data to Http with content type: application/x-www-form-urlencoded

I think you need to URL-encode the parameters in your payload. The password needs it in this instance, and it's worth doing for the username too. So, you would have: String payLoad = 'grant_type=...
Aidan's user avatar
  • 13.8k
8 votes
Accepted

Communicating between Lightning Aura component and VF Page

Finallyyyyyyyy I figured out !!! I had set development mode on in my user profile**** because of which I was getting the following error. Uncaught DOMException: Blocked a frame with origin ...
Rao's user avatar
  • 16.7k
7 votes

How to pass @httppost parameters in apex integration?

The only thing you need to do is retrieving body of the post request, this can be done like in the example below: @HttpPost global static void processPost() { Map<String, Object> ...
Mariia Illarionova's user avatar
6 votes
Accepted

How to insert multiple records in an object using REST API post method in workbench

Create Multiple Records using rest API Documentation While the SObject Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same type. In a ...
Ratan Paul's user avatar
  • 22.7k
6 votes
Accepted

RestResource Annotation - What is the urlMapping To?

That tells you the URL path. So when you want to hit your service you would use: /services/apexrest/CompanyData/
Adrian Larson's user avatar
  • 151k
5 votes

Send Blob file via Apex Rest Callout

You can't use both setBody and setBodyAsBlob in the same request. Also, if you're using multipart/form-data, you have to build a multipart payload. That means that you'll need to do something like the ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

How to properly send a Json in the body of a POST request?

As the documentation states, setBody accepts a String argument. In this case, you need to serialize the model. JSON2Apex payload = new JSON2Apex(...); request.setBody(JSON.serialize(payload)); I'd ...
Adrian Larson's user avatar
  • 151k
4 votes

Send Blob file via Apex Rest Callout

Proper multipart/form-data POST requests from Apex are tricky. As @sfdcfox mentioned, you need to do some very careful manipulations between the 8-bit bytes of the input file and the 6 bit groups used ...
Daniel Ballinger's user avatar
4 votes

How to give date and time values in request body using postman

I tried this in the workbench. It successfully created an event record. I suspect salesforce is expecting a date in a standard format instead of the date(value) format. { "Type":"contact call", ...
abhi's user avatar
  • 1,810
4 votes
Accepted

Help with Rest Resource

You need to annotate your POST handler method with the @httpPost decorator. That way Salesforce knows to run that method when the REST Request method from outside is set to "POST". It should ...
John Thompson's user avatar
4 votes
Accepted

How to get Refresh Token in Postman in 2024?

Only certain flows provide you with a refresh token, and the Client Credentials flow is not one of them. The User-Agent flow (a.k.a. the "implicit" flow/grant type) can return a refresh ...
Derek F's user avatar
  • 62.8k
3 votes
Accepted

Send Blob file via Apex Rest Callout

Thanks for all of your valuable feedback. Below example worked for me with some modifications. How can I compose a multipart/form-data request? Here is my code. File Upload Method public void ...
MalindaL's user avatar
3 votes
Accepted

Calling a flow through REST api returns "http body is required" error

flow expect input parameters while calling through API so you need to pass blank input array if you are not passing any value. Update your body with following json { "inputs": [ {} ] } So your ...
Himanshu's user avatar
  • 10.5k
3 votes
Accepted

Creating REST Api with little control over request structure

One method you could try would be to set up a public force.com site, and allow the public user access to your global Apex class. An alternative to that method is to set up an intermediary web server (...
Derek F's user avatar
  • 62.8k
3 votes
Accepted

POST Ajax method with Jquery to create new account contact and Opportunity

You can use the SObject Tree resource to create nested records. POST /services/data/v42.0/composite/tree/Account HTTP/1.1 Host: <instance>.my.salesforce.com Authorization: OAuth ... Content-...
sfdcfox's user avatar
  • 497k
3 votes

If we change the parameters used in webservice method in our org., will this cause error at end user consuming old WSDL?

Yes, Some WSDL has strictly typed XML validators, you change a single thing and hell break loose. It will break as it won't find the exact match for a method with exact parameters, it would just break ...
Pranay Jaiswal's user avatar
3 votes
Accepted

Can we use a map in HttpPost to make our code shorter? (too many fields and we can add more in future)

you can create create WrapperClass for Ticket, create JSON object and send it as param of request @HttpPost global static Ticket__c postT(TicketWrapper wrapper){ Ticket__c thisT = wrapper....
Oleksandr Berehovskyi's user avatar
3 votes
Accepted

post Event for a lead getting incorrect type for WhatId

You are supposed to use WhoId. WhoId: The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact’s ID or a lead’s ID. The ...
Hemavantha Rajesh Varma Mudunu's user avatar
3 votes

rest post execution of AfterInsert caused by: System.NullPointerException: Argument cannot be null

This error is fairly self-explanatory. You're passing a null value to EncodingUtil.urlEncode and that's not allowed. You only call that method at one location: req.setBody(',parameters: {LeadID='+...
David Reed's user avatar
  • 93.2k
3 votes
Accepted

dynamic json body as http post request

You need to pass the parameters to GetUrlRequest by changing it to method: public class RequestWrapper { public static GetUrlRequest GetUrlRequest(String cId, String sBC, String pur, abc abc, ...
salesforce-sas's user avatar
3 votes

How to Make Pardot Authorisation Request?

Not so long ago, Pardot changed the authentication method so that you can no longer put the username and password in the URL of the request. You need to put them in the request body. See the current ...
Aidan's user avatar
  • 13.8k
3 votes
Accepted

Unittest not covering webservice

As with any other method you want to cover, you have to actually call it. @IsTest static void myTest() { // setup as is Test.startTest(); DynamicApi.DynamicApiPost(); Test....
Adrian Larson's user avatar
  • 151k
3 votes
Accepted

System.TypeException: Invalid decimal in Rest Resource @HttpPost

The error is telling you exactly what is wrong. System.TypeException: Invalid decimal: 30,000 30,000 is not a valid numeric literal in Apex. (The comma, specifically, is disallowed). Consider ...
David Reed's user avatar
  • 93.2k
2 votes
Accepted

Bulk Records Using Rest Services - getting soql 101 error

This question may be the most basic possible bulkification question. Never query in a loop. In this instance, you do not need to query at all. If you have a record's Id, you can update it without ever ...
Adrian Larson's user avatar
  • 151k
2 votes
Accepted

Rest Services using Apex class

How to deserialize a JSON String to Apex Use http://json2apex.herokuapp.com/ to generate you class and save that class in your salesforce org now in your rest service class @RestResource(...
Ratan Paul's user avatar
  • 22.7k
2 votes
Accepted

How to Write a apex class to get the json input Values from postman

You can create a Apex class with https://json2apex.herokuapp.com/ and deserialize it. JSON2Apex jsnApx = (JSON2Apex)JSON.deserialize(body1, JSON2Apex.class); system.debug('@@@ = '+jsnApx.whatid); ...
Saroj Bera's user avatar
  • 14.8k
2 votes

POST Ajax method with Jquery to create new account contact and Opportunity

The response of the first call (Account) will contain the Id you need to then make the 2nd (Contact) and 3rd (Opportunity) calls. See here for the format. So, after making your first call, if ...
Sebastian Kessel's user avatar
2 votes

If we change the parameters used in webservice method in our org., will this cause error at end user consuming old WSDL?

Yes you need to share updated WSDL with them if you change parameter in method. Users with old WSDL will not be able to use it. If you change anything inside method body this will not affect them. ...
Tushar Sharma's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible