Validating API URL with JWT Session Token

Hi There!

I am trying to perform a simple API validation based on a URL using a JWT Session Token which is changing every session. Here is my code and the error I get;
Error
SyntaxError: Unexpected token T in JSON at position 0
Method Not Allowed 405

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: 'URL',
    headers: {
      'Authorization': 'Bearer ' + parsed_body["access_token"]
    }
  };

  $http.get(api_request, new_relic_callback);
};

var token_request = {
  url: 'URL',
  form: {
    client_id: "MYCLIENTID",
    client_secret: "MYSECRET",
        grant_type: "client_credentials"
  }
};

$http.post(token_request, api_request_callback);

Hey @Anthony.Eaton Sorry to hear that you’re getting this error and that so far there hasn’t been a response from the community. I’ll bring your issue up to our support team to see if they can provide some help here. Thanks for your patience :slight_smile:

Joi

@Anthony.Eaton I’m going to put this over in our Data Queries space to get more visibility with community members who like to help with building scripts.