Cant up date a PO using PUT

Description

Trying to change / add a PO Instruction field

When I did:

Sent PUT request to PO endpoint as per documentaion… /purchase_order/po_id/ with correct payload.

Ordoro returned … "A purchase order already exists with that po_id…

Is it true PO can not be changed from API?

Hey RELSTON,

The PUT endpoint should work. If you can post the x-api-request-id response header here I can take a look at the logs and see what’s going on.

Here you go:

X-API-REQUEST-ID: 62fe74d7-646c-40a7-b391-f71441dda079

{“error_message”: “A purchase order already exists with that po_id ‘20200924-RLETEST’ for company_id 430062”, “param”: null}

here is hson object sent:
{“po_id”:“20200924-RLETEST”,“supplier”:51734,“warehouse”:48037,“shipping_amount”:0.0,“tax_amount”:0.0,“discount_amount”:0.0,“shipping_method”:" another AS400 Spot",“payment_method”:“AS400 SO#: 2567890”,“instructions”:"These are special instructions newly PUT”}

sent PUT to:
https://api.ordoro.com/purchase_order/20200924-RLETEST/

This is an existing PO. need to update one of the text fields - shipping_method, or payment_method or instructions……

any length limits on any of these? or must Shipping_method or Payment_method be predefined in Ordoro?

Thanks for any help you can provide. …

Ahh, I see what’s going on. You’ll want to exclude po_id from the BODY when PUTting unless you actually want to change the po_id to something else.

It is checking to make sure the po_id in the body doesn’t already exist before it changes it, which it does in this case because it’s the PO you’re updating.

In general, most of our PUT methods only require you to send the elements that you’re updating, so they behave more like PATCH.

1 Like

Thanks.
I thought it a bit strange that the end point also specified the PO_ID.

So documentation should be updated…

Also if I wanted to PUT a new PO would I put the new po_ID on the endpoint url and also leave out the po_id in the payload?

Or PUT to the /purchase_order/ endpoint and include the new po_id I want?

Thanks again.
Richard

PastedGraphic-12.png

Yes, it is in our pipeline to completely overhaul our API documentation and we’ll post any updates here on the forum.

Regarding POs…
Creating POs is a bit of a rabbit hole. Right now there is no POST method on the /purchase_order/ endpoint, and PUTting can only update, not create.

POs are currently created with the /product/<sku>/buy/<supplier_id>/ endpoint. This endpoint will either create or update an existing PO depending on the elements passed and whether or not a matching PO is already open.

The body for the endpoint takes the following:

POST /product/<sku>/buy/<supplier_id>/

{
  "warehouse": <warehouse_id>,
  "quantity": <quantity of sku>,
  "unit_price": <unit price of sku>
}

If you already have a PO open for supplier A, warehouse 123 and you POST to the buy endpoint with another sku, it’ll append it to the currently open PO. If there is no open PO with the supplier/warehouse combo then it’ll create a new one.

Similarly, if the sku already exists on the PO, then it’ll check to see if the unit price is the same. If it is, then it’ll simply add the quantities to the existing line. If the unit price is different then it’ll add a new line with the quantity at the different unit price.

We do have plans to add a POST endpoint for purchase orders and I’ll update you here on the forum when we do.

1 Like

Thank you.
A followup qiestion, I could test but maybe you could answer… Can I change a po_id by sending a different po-id in payload to the endpoint of the original po-id?
Ex PUT to /purchase-order/1234/ with a po-id of 5678 in the po-id field of the json payload?

Yep

PUT /purchase_order/1234/
{
  "po_id": "5678"
}

This will change the ID from 1234 to 5678. Any subsequent requests would be to /purchase_order/5678/

1 Like