POST Request body is giving error for grant type

Synthetics question template

Hi Team,

I am trying to build a synthetic to do a POST call to SFMC to get the access token and while testing I cloud see that it is giving an error for grant type. Where as the same code is working as expected in the POSTMAN tool.

Could please help me with this issue.


var info, token;
var assert = require(‘assert’);
var $http = require(‘request’)

var options = {
uri: '',

body: {

headers: {
'Content-Type': 'application/json',

$,function (err, response, body) {
info = JSON.parse(body);
console.log(‘Security token retrieved successfully’);
assert.ok(response.statusCode == 200, ‘Expected 200 response’);

Synthetic Link:

This issue is fixed. Below sample code snippet was helpful in fixing this issue. Thanks

var assert = require('assert');

function new_relic_callback(err, response, body) {
  assert.equal(response.statusCode, 200, 'Expected a 200 OK response');

function api_request_callback(err, response, body) {
  var parsed_body = JSON.parse(body); 
  var api_request = {
    url: '',
    headers: {
      'Authorization': 'Bearer ' + parsed_body["access_token"]

  $http.get(api_request, new_relic_callback);

var token_request = {
  url: '',
  form: {
    client_id: "YOUR_CLIENT_ID",
    client_secret: "YOUR_CLIENT_SECRET",
    grant_type: "client_credentials"

$, api_request_callback);
1 Like

@raju.shekar Thank you for sharing that you were able to find a solution and the sample code! :slight_smile: