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

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
  • 14k
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.8k
7 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
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
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
  • 502k
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

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,830
4 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
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
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
  • 64.1k
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
  • 64.1k
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 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
  • 502k
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

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.7k
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
  • 14k
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.7k
2 votes
Accepted

Callout REST HttpPost: how to create an object with all fields?

You are parsing SObject here public static App__c ParseRequest(RestRequest req) { App__c app = new App__c(); String body = req.requestBody.toString(); app = (App__c)JSON....
Barış Arslan's user avatar
2 votes
Accepted

Is it possible to create a Data Extension in a custom Activity?

Custom activity would not have direct access to the Marketing Cloud, since it will be hosted outside of it.However you can create data extension via API, by implementing SOAP API call manually or by ...
Ros Haitovich'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
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

How to send Form Data to DE without hitting submit button using AJAX and AMPscript

I don't have an immediate answer for your script issue, but I have some words of advice and guidance which might save you in the long-term. You intended script will post to a SFMC cloud page upon ...
Gravitai's user avatar
  • 2,850
2 votes

Test for HttpPost service: how to take JSON body for test?

The only real differences between testing an Apex webservice, and testing a "normal" Apex class is that you'll be providing input via RestContext.request, and gathering output via RestContext.response....
Derek F's user avatar
  • 64.1k
2 votes

Error in Json for Rest Api

You will typically end up with less code and less buggy code if you create your own Apex class that has the field names and types you want, set the values there and then push that through JSON....
Keith C's user avatar
  • 137k

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