ineersa
ineersa

Reputation: 3435

Is there any way to send empty optional query parameters?

I'm writing documentation for API, and got problem.

Here is link definition:

### Get hotels availability [GET /agent/v1/hotel/availability{?regions,hotels,from,to,limit,offset}]

Parameters:

+ Parameters 
    + regions (required,string,`399,189`)
    + hotels (optional, string, `1844`)
    + from (optional, string, `2016-03-12`)
    + to (optional, string, `2016-03-19`)
    + limit (optional, number, `1`)
    + offset (optional, number, `0`)

When I'm trying to send request with empty hotels parameter for example, apiary uses 1844 instead of empty. If I'll try to example it to empty, hotels=hotels is sended.

Is there any way to send empty for optional parameter, or not send it at all?

Here is link with screenshot: http://www.awesomescreenshot.com/image/1008356/09614be501945b0644fd84a06e311404

Upvotes: 1

Views: 553

Answers (1)

Honza Javorek
Honza Javorek

Reputation: 8796

I'm not sure whether I understand your problem correctly. I tried to reproduce the behavior you described. I created a new API Project in Apiary and wrote following API Blueprint:

FORMAT: 1A

# Hotels API

# Group Hotels

## Hotels [/agent/v1/hotel/availability{?regions,hotels,from,to,limit,offset}]

+ Parameters 
    + regions (required,string,`399,189`)
    + hotels (optional, string, `1844`)
    + from (optional, string, `2016-03-12`)
    + to (optional, string, `2016-03-19`)
    + limit (optional, number, `1`)
    + offset (optional, number, `0`)

### Get hotels availability [GET]

+ Response 200 (application/json)

        {"hello":"world"}

Then I opened console pane in the generated interactive documentation and tried to edit URL parameters:

editing URL parameters

The URL at the top is changing correctly. I made some requests with the Console and the Traffic Inspector page seems to confirm that correct parameters has been sent:

enter image description here

I think you'll have to refine your question and provide more information. Also, I believe this is fairly Apiary-specific topic and it may make more sense to contact Apiary Support at [email protected] instead. If e-mail isn't your thing, there's also an interactive chat:

enter image description here


Disclaimer: At the time of writing the answer I work for Apiary.

Upvotes: 5

Related Questions