How do I handle this type of API response data in Bubble?

Error parsing data from Apiconnector2:

data: {"id": "cmpl-6pz3mk20DODvGh4VchcIeyWgtsB0m", "object": "text_completion", "created": 1677847462, "choices": [{"text": "\n", "index": 0, "logprobs": null, "finish_reason": null}], "model": "text-davinci-003"}

data: {"id": "cmpl-6pz3mk20DODvGh4VchcIeyWgtsB0m", "object": "text_completion", "created": 1677847462, "choices": [{"text": "Ste", "index": 0, "logprobs": null, "finish_reason": null}], "model": "text-davinci-003"}

data: {"id": "cmpl-6pz3mk20DODvGh4VchcIeyWgtsB0m", "object": "text_completion", "created": 1677847462, "choices": [{"text": "pping", "index": 0, "logprobs": null, "finish_reason": null}], "model": "text-davinci-003"}

data: {"id": "cmpl-6pz3mk20DODvGh4VchcIeyWgtsB0m", "object": "text_completion", "created": 1677847462, "choices": [{"text": " into", "index": 0, "logprobs": null, "finish_reason": null}], "model": "text-davinci-003"}

data: {"id": "cmpl-6pz3mk20DODvGh4VchcIeyWgtsB0m", "object": "text_completion", "created": 1677847462, "choices": [{"text": " my", "index": 0, "logprobs": null, "finish_reason": null}], "model": "text-davinci-003"}

data: {"id": "cmpl-6pz3mk20DODvGh4VchcIeyWgtsB0m", "object": "text_completion", "created": 1677847462, "choices": [{"text": " living", "index": 0, "logprobs": null, "finish_reason": null}], "model": "text-davinci-003"}

data: {"id": "cmpl-6pz3mk20DODvGh4VchcIeyWgtsB0m", "object": "text_completion", "created": 1677847462, "choices": [{"text": " room", "index": 0, "logprobs": null, "finish_reason": null}], "model": "text-davinci-003"}

data: {"id": "cmpl-6pz3mk20DODvGh4VchcIeyWgtsB0m", "object": "text_completion", "created": 1677847462, "choices": [{"text": " is", "index": 0, "logprobs": null, "finish_reason": null}], "model": "text-davinci-003"}

You cannot. YOu will need to set the API data type to TEXT. This is not a json. You will need to modify this response to be able to use it. Some JSON tool may help you display and use this payload, but you will need to modify the response by removing all “data:”, adding [] aroun the payload and a comma between each object.

2 Likes

Thanks Jici for your response.

I changed the data type to text and the initialization worked. However, I don’t know how to modify the response so that I can grab and display the value of “text” (inside the array named choices).

1 Like