how to post an array of object parameters?

40 views
Skip to first unread message

Eddard

unread,
Apr 4, 2016, 12:49:37 PM4/4/16
to Guzzle - PHP HTTP client and REST client framework
Hello 

i am trying to post this object 
  "product": {
      "d": 80580250,
      "product_code": 1000250,
      "name": "vacuum cleaner",
      "locations": [
        {
          "retailer_id":"12400012",
          "stick": 2000
        },
        {
          "retailer_id":"12400014",
          "stock": 400
        }
      ]
    }
}

i am having a problem with the locations parameter, how do how write the service description so it doesn't translate to this 
"locations":[
{},
{}
] ?


thanks in advance
Eddard

Eddard

unread,
Apr 4, 2016, 11:37:51 PM4/4/16
to Guzzle - PHP HTTP client and REST client framework

So far based on Guzzle Doc here is what i have been able to come up with, but when logging the request the locations parameter is an array of empty object.

'parameters' => array(
                'id' => array(                      
                    'location' => 'json',
                    'type' => 'integer',
                    'required' => true,
                ),
                'product_code' => array(
                    'location' => 'json',
                    'type' => 'string',
                    'required' => true,
                ),
                'name' => array(
                    'description' => 'vacuum cleaner',
                    'location' => 'json',
                    'type' => 'string',
                    'required' => true,
                ),

                'locations' => array(
                    'location' => 'json',
                    'type' => 'array',
                    'required' => true,
                    "items" => array(
                        "type" => "object",
                        "properties" => array(
                            "retailer_id" => array(
                                "location" => "json",
                                "type" => "integer"
                            ),
                            "stock" => array(
                                "location" => "json",
                                "type" => "integert"
                            )
                        )
                    )
                ),
            ),
        ),
Reply all
Reply to author
Forward
0 new messages