0

Using Apiary.io, is it possible to POST requests to the same endpoint, which contains different content in the body, and return different HTTP 201 responses, based on the request body?

Only, we have an API that returns calculated data based on data it receives in the request. The data in the request is sent via POST because the amount of data can be too much for GET to cope with.

The following isn't an example of my data, but is an example of what I'm trying to achieve. A single endpoint, but two requests and two responses; so if the first request is sent, the first response should be returned, and if the second request is sent, the second response is returned.

## Example Collection [/example]

### Create a New Example [POST]

An example.

+ Request (application/json)

        {
            "ExampleId":"A9F4B93A-4C02-462A-87C5-CF1EAD732A46"
        }

+ Response 201 (application/json)

    + Headers

            Location: /example/1

    + Body

            {  
                "result":"dkk4948djjdf8i49"
            }

+ Request (application/json)

        {
            "ExampleId":"97E8DD35-5A30-47ED-B92D-80D110A3AD0B"
        }

+ Response 201 (application/json)

    + Headers

            Location: /example/2

    + Body

            {  
                "result":"05ikflk30gdgg"
            }
metalhead
  • 21
  • 4

1 Answers1

0

Unfortunately Apiary's Mock server isn't able to do that (yet).

As a workaround, you can use the Prefer to ask for a particular response, based on the returned status code.

Vincenzo
  • 1,549
  • 1
  • 9
  • 17