Could not parse Json body of your request error

I am trying to integrate ChatGPT with StudioX. I am trying to generate the request payload dynamically by passing a dynamic prompt. Since StudioX does not support variables I am facing hard time to get this done. I am trying to send the following text to body of HTTP Request activity

“{”“model”“:”“text-davinci-003"”,““prompt””:“”“+Saved.Values(Of String)(“queryText”).ToString+”“”,““temperature””:0.7,““max_tokens””:256,““top_p””:1,““frequency_penalty””:0,““presence_penalty””:0}"

But I get invalid Json error. If hardcord the value instead of using queryText, I get desired output. When I print the following through a message box, I can see queryText is replaced by the correct query text. What I am doing wrong here?


Which way did you check it by, actual-run or wizard? if wizard, it doesn’t support variable. Can you check it by actual run?

If actual-run, can you try to output both case (direct coding and variable) to text file and compare them ( or share them here)?


I tried trough both Wizard and UiPath assistant, but both give me the same result. Is it possible to output the request body from HTTP Request activity?, I see very less debug options as it is StudioX

The response is

    "error": {
        "message": "We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to and include any relevant code you'd like help with.)",
        "type": "invalid_request_error",
        "param": null,
        "code": null

Hey build it like this:
New JObject( New JProperty("headers", New JObject( New JProperty("X-UIPATH-OrganizationUnitId", "61890") ) ) )

Type of variable is JObject and latere to JObject.tostring


Can you try as the following? (Output 2 text files : hardcoding case and the above expression.

Then compare them using text editor (notepad) (or share them here)


I got the issue. The request body is generated something like below. Here I can see a newline is introduced at the end of the message


I read the prompt text from Word file using Use Word File activity. But the problem is that it automatically appends a new line at the end of the prompt (here Hello). Why is this happening?


If there is extra whitespace including linbreak at the end of the content, Trim method will help you.

Saved.Values(Of String)("queryText").ToString.Trim