Search code examples
jsonrestapiary

Apiary JSON request parameter testing


Is there a way to test JSON request with parameters with Apiary?

Currently, I have a simple API with a JSON request with a few parameters laid out using the + Parameters tag but that is currently throwing warnings as those tags have not been included in the URI template. See below.

# Group Authentication

## Registration [/registeruser]
### Regster User [POST]

+ Parameters

    + id (string) ... Unique.

+ Request (application/json)

        {
            "fb_id": "1097642000199029910322322987867",
            "fb_token": "84uh8dsu9f84932h098dhsfhdsjf94021",
            "fb_token_type": 1
        }

+ Response 200 (application/json)

        {
            ...
        }

Further, I am unable to test these parameters in the console provided. Is this not supported or am I doing something wrong?


Solution

  • The Parameters is used for defining URI template parameters. When you define an item in Parameters, it should reference a field in your URL. For example:

    # Group Authentication
    
    ## Registration [/registeruser/{id}]
    ### Regster User [POST]
    
    + Parameters
    
        + id (string) ... Unique.
    
    + Request (application/json)
    
            {
                "fb_id": "1097642000199029910322322987867",
                "fb_token": "84uh8dsu9f84932h098dhsfhdsjf94021",
                "fb_token_type": 1
            }
    
    + Response 200 (application/json)
    
            {
                ...
            }
    

    Notice I've added {id} to the URL. This corresponds to the id listed in the Parameters section. You are getting the error in your warning because there is no {id} in the URL.