Hi,
I am trying to use the below in the Request body while calling the OpenAI API via the Invoke web service of the Power Automate Desktop RPA tool.
{
“model”:“text-davinci-003”,
“prompt”:“What is the capital of India?”,
“temperature”:0,
“max_tokens”:100,
“top_p”:1,
“frequency_penalty”:0.0,
“presence_penalty”:0.0
}
However, after several modifications I am unable to determine what is the wrong in the above Request as I am constantly getting the below error.
{
“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 support@openai.com and include any relevant code you’d like help with.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
Thank you very much for pointing me to the right URL.
The new URL I am using is https://api.openai.com/v1/completions
and the Request is
{
“model”: “text-davinci-003”,
“prompt”: “Say this is a test”,
“max_tokens”: 7,
“temperature”: 0,
“top_p”: 1,
“n”: 1,
“stream”: false,
“logprobs”: null,
“stop”: “\n”
}
However I am seeing the same error as below.
What else could be different?
{
“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 support@openai.com and include any relevant code you’d like help with.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
Could you please clarify what you meant by “object was jsonified”?
The request I am passing is already a json format.
Tried Content type with and without utf-8 (application/json; charset=utf-8)
{
“model”: “text-davinci-003”,
“prompt”: “Say this is a test”,
“max_tokens”: 7,
“temperature”: 0,
“top_p”: 1,
“n”: 1,
“stream”: false,
“logprobs”: null,
“stop”: “\n”
}
Thank you for your responses.
Finally I have received the output.
After the change in URL suggested by @Dent I had to disable the attached “URL encoding” option which was enabled by default.
Can you please guide me where i have to disable this option as i am getting same error through power-automate using web. @Dent can you please help here how can i disable URL encoding for cloud flows?