42
Views
1
Comments
[ardoJSON] JSON_Objectify error: "Object reference not set to an instance of an object."
ardojson
Service icon
Forge asset by João Barata
Application Type
Service
Service Studio Version
11.54.84 (Build 63795)

We are making a request to an REST API.

The API expects one of the objects to have the following JSON structure: 

"properties" : {

    { "key_1" : "value_1" }, 

    { "key_2" : "value_2" } 

}, hence generate the "properties"  as a list of items that contain a key/value pair as values like the example below. And then, use JSON_Objectify in the OnBeforeRequest to get the above expected result.

"properties" : [

    { 

       "key" : "key_1" ,

      "value" : "value_1" 

    }, 

    { 

       "key" : "key_2" ,

      "value" : "value_2" 

    },

]

The issue here, is when we call the JSON_Objectify in the OnBeforeRequest, it throws the error "Object reference not set to an instance of an object." but if I manually pass the request as a JSON in the demo, it works. Could you please help us understand what could be the issue here?

The path we used is: "tools.function.parameters.properties"

Thanks.

In the attachments you may find "request-body.txt" which is the request example the action gets as input parameter and the "request-body-json.txt", which is the same content as .txt, but in JSON format.

request-body.txt
request-body-json.txt
2024-02-16 07-43-18
Amit Verma

Hi Luiz,

Just to clarify, is the following output what you're looking for? 

{{

  "properties": [

    {

      "key": "prompt",

      "value": {

        "type": "string",

        "description": "The prompt that will be used for the function_name."

      }

    },

    {

      "key": "n",

      "value": {

        "type": "integer",

        "description": "The number of times the prompt should be used."

      }

    }

  ]

}}

Thanks,

Amit

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.