Data Broker Server Script: Syntax error

Jamshaid
Tera Contributor

I have written a Transform Data resource to fetch JSON data using Rest API with the following code:

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://dummyjson.com/products/1');
request.setHttpMethod('GET');
request.setRequestHeader("Accept", "application/json");

var response = request.execute();
gs.log(response.getBody());

When I run this transform script, it throws syntax error as follows:

      "sourceName": "sys_ux_data_broker_transform.f41c85c7871e0910afa7206f8bbb3597",
      "lineNumber": 1,
      "lineSource": "(var request = new sn_ws.RESTMessageV2();",
      "columnNumber": 5,
      "errorMessage": "syntax error",
      "name": "SyntaxError",
      "message": "syntax error",
      "localizedMessage": "syntax error",
      "scriptStackTrace": "",
      "scriptStack": [],
      "suppressed": []
    },
    "logMessage": "Data Broker Server Script: 'Test Jamshaid' : Line(1) column(5)\n(var request = new sn_ws.RESTMessageV2();",
    "name": "SyntaxError",
    "message": "syntax error",
    "lineNumber": 1,
    "localizedMessage": "syntax error",
    "suppressed": []
  }
]

I am unable to get what is wrong with my script. Could anyone please help me figure this out? Thanks

find_real_file.png

3 REPLIES 3

AnirudhKumar
Mega Sage
Mega Sage

I think it could be a scope issue.

I see you are in the application scope called Test 1. Can you check if there is any Restricted Caller Access Privilege record asking for 'Allowed' permission

There was an error and I added the admin permission and the error was gone. how do i check what you suggested?

Guido Bernuetz
Giga Guru

the 1st line should be:

function transform(input) {

I am not a helpful hunter.
I will always try to give a meaningful and valid answer.