JSON error, but it works internally.

Options

"I built an API that consumes the following JSON:

{
"endereco_cliente_id": 21,
"ofertas_quantidade": [
{
"oferta_id": 1,
"quantidade": 1
},
{
"oferta_id": 5,
"quantidade": 1
}
]
}

However, when I use it in Swagger, it returns a different result compared to Xano, and Postman is other result. With the same payload and everything identical, it throws an error. Have any of you encountered this issue? Please note that one of the input items is an object.

Answers

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    edited October 2023
    Options

    Hey @myrko! 👋

    Can you provide us with more information about the error you are seeing and what the endpoint is doing?

    Just a guess, but I'm wondering if you are getting the error because the "method" you are using is GET, and your endpoint is performing a different operation.

    API Endpoint verbs

    API Endpoints have a "method" or HTTP Verb associated them and the most common are POST, GET, PUT, PATCH, and DELETE. These verbs correspond to the CRUD (Create, Read, Update, Delete) operations, respectively. When you create an API endpoint, you must first define what type of verb it is.

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    I suspect the problem here is you mean a POST request. GET requests can't consume JSON directly because search strings (The part after the question mark in a URL) are form-encoded. I bet you mean to put it in the "body" of the request, and that implies a POST. Changing the type of the request likely clears it up!