1

I did all the necessary steps and manage to work it via the get functionality with no issues at all.

For the post (Though it is actually on Beta) I am stuck on this specific screen:

enter image description here

What value is it actually referring to? I am not sure.

I am trying to Integrate it with OpenAI .

Endpoint: https://api.openai.com/v1/completions

Sample request:

{
  "model": "text-davinci-003",
  "prompt": "What gifts should I buy for Christmas?",
  "max_tokens": 64,
  "temperature": 0.5
}

sample response:

 {
"id": "cmpl-7TLuEpDJ3LiAtu6li5XcOG0VBT1J4",
"object": "text_completion",
"created": 1687230074,
"model": "text-davinci-003",
"choices": [
    {
        "text": "\n\n1. Books \n2. Clothing \n3. Electronics \n4. Toys \n5. Jewelry \n6. Home Decor \n7. Gift Cards \n8. Kitchen Appliances \n9. Personalized Mugs \n10. Video Games",
        "index": 0,
        "logprobs": null,
        "finish_reason": "stop"
    }
],
"usage": {
    "prompt_tokens": 8,
    "completion_tokens": 60,
    "total_tokens": 68
}

}

EDIT: Added an endpoint , request and response.

4
  • You need to generate the actual body of the request to pass into that input value. When you set up the HTTP Callout it will have generated a number of Apex classes that represent the data structures that the callout expects in the body. Within your flow you'll need to create a variable that uses those Apex Defined Data Types that you can then use as the body. Commented Jun 19, 2023 at 2:53
  • @Callum MacErlich That does not work as well as you think. One example: salesforce.stackexchange.com/questions/399719/…
    – identigral
    Commented Jun 19, 2023 at 16:39
  • That's fair, I made an assumption on the structure of the request itself. @Snorlax would you be able to share the exact endpoint you're calling and maybe an example request structure if available? Commented Jun 19, 2023 at 20:42
  • I tried your approach and still failed. @cal
    – Snorlax
    Commented Jun 20, 2023 at 2:58

1 Answer 1

1

I had the same problem and I've finally worked out how to set the Body.

1 - Creating the body variable

  • List item
  • Create a "Body" variable which will be an Apex-Defined Variable (it's managed automatically in the External Services created by Salesforce).

2 - Once you have created the "Body" variable, you need to

  • Add an Assignment component
  • Add the Body variable
  • Is equals to
  • Create a text formula variable (used to define the content of your body)

SetBody Assignment

3 - To process the content of the JSON response

  • Create a Text Template variable (which takes the content of the response 2XX.Data.[xxx])

At this point your JSON is interpreted as Text and you can use it in a formula or other.

Resources :

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .