picqer / picqer-php

PHP Client for the Picqer API
https://picqer.com/en/api
MIT License
18 stars 23 forks source link

Create new purchase order #8

Closed jasondecode closed 6 years ago

jasondecode commented 6 years ago

I can't create any purchase orders. When i look at the client.php, i cant find any method for it.

I tried to create my own request:

public function addPurchaseorders($data)
{
     return $this->sendRequest('/purchaseorders', $data, self::METHOD_POST); 
}

this will make a post request to: https://example.picqer.com/api/v1/purchaseorders as it is indicated in the picqer documentation: https://picqer.com/en/api/purchaseorders#h-create-new-purchase-order

But no success, when i pass a warehouse or supplier id that doesn't exists it will return a valid error message but when i send the correct data it will return a HTML string in the error message.

picqer issue

casperbakker commented 6 years ago

That 500 error is totally our mistake, we will fix that.

I see in our exceptions logging that you did not gave an array of products to the products key, but only gave an object of 1 product.

If you give an array of products to that key, it should work with your request.

You sent us:

{
  "idsupplier": 333,
  "idwarehouse": 333,
  "products": {
    "idproduct": 333,
    "price": 12,
    "amount": 1
  }
}

But it should be like this:

{
  "idsupplier": 333,
  "idwarehouse": 333,
  "products": [
    {
      "idproduct": 333,
      "price": 12,
      "amount": 1
    }
  ]
}
jasondecode commented 6 years ago

@casperbakker Thanks for your reply! i was kind of confused because of the error message but the problem was just on my side, thanks for correcting me and i really appreciate it!