How do you make HTTP GET, POST, PUT, and DELETE calls in SSJS?
Suggested answer
SSJS provides the HTTP object (on CloudPages) and Platform.Function.HTTPGet/HTTPPost for API calls from Script Activities:
HTTP.Get(url): Returns a string response. No header control.
HTTP.Post(url, contentType, body): Sends a POST request.
For full header control (needed for authenticated REST API calls) use HTTP.Get(url, headerNames[], headerValues[]) and HTTP.Post(url, contentType, body, headerNames[], headerValues[], statusCode).
PUT/DELETE: Use HTTP.Post with a header X-HTTP-Method-Override: PUT or DELETE, since SSJS HTTP does not have native PUT/DELETE methods. Alternatively, use WSProxy for SOAP-based operations or call Marketing Cloud's own REST endpoints via HTTP.Post with appropriate method overrides.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.