Try ERPNext Buy Support Partners Foundation

Erpnext.selling.doctype.sales_order.sales_order.make_delivery_note

Good Day

I need help to create a delivery note from an order via api call.
I use Insomnia for testing purposes and can get data from the following link:

http://domain/api/method/erpnext.selling.doctype.sales_order.sales_order.make_delivery_note, but not sure how to create Delivery Note (Saved / Draft) State.

Not sure if this api call with some parameters will save new Delivery Note from Sales Order, or do i need to call another post with json from previous post?

Hope someone could help me out.

Thank You

Albertus Geyser

The MandatoryError is telling you that obligatory values have not been provided.

Also, you cannot POST :

["message": { "_isLocal": 1, etc.,etc.}]

You must instead only POST

{ "_isLocal": 1, etc.,etc.}

In the other text you mention, ( How to create invoice from sales order using API ), thats the purpose of the jq command:

jq .message ./freshFromTheOven.json > hotButtered.json;

Good Day

Thank you for taking the time to answer my question.

Is there any way to do this in Postman / Insomnia to understand how this is working?

I found the following, but would like to understand how this is working:

declare A_SALES_ORDER="SAL-ORD-2020-00001";
declare ERPNToken="ec226d15b52879e:934bad7c3fadda0";
declare YOUR_HOST="dev.yourpublic.work";

curl -slX POST "https://${YOUR_HOST}/api/method/erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice" \
    -H "Authorization: token ${ERPNToken}" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    --data-urlencode "source_name=${A_SALES_ORDER}" \
> freshFromTheOven.json;

jq .message ./freshFromTheOven.json > hotButtered.json;

curl -slX POST "https://${YOUR_HOST}/api/resource/Sales%20Invoice" \
    -H "Authorization: token ${ERPNToken}" \
    -H "Content-Type: application/json" \
    -d @./hotButtered.json \
> jellySandwich.json;

jq .data ./jellySandwich.json;

Thank You once again.

Albertus Geyser

Good Day

I had a look at when i remove the [“message”: it gives me the following:

Is there a way to do this with Postman / Insomnia?

Thank You

Albertus Geyser

I have tried to the same sequence of steps;

  1. Create sales order and submit on ERPNext. Get the Document ID: SO-0101910
  2. Use https://example.com/api/method/erpnext.selling.doctype.sales_order.sales_order.make_delivery_note?source_name=SO-0101910 to get the payload that will create the Delivery Note
  3. Remove the message wrapper tag as highlighted by @MartinHBramwell
  4. Create the Delivery Note using https://example.com/api/resource/Delivery%20Note
  5. The Delivery Note is created as expected.

Something to note is I tested using the latest v12 stable release:
Frappe: v12.15.0 (version-12)
ERPNext: v12.18.0 (version-12)

Good Day All my ERPNext Friends

I manage to get it working with help of my friends.

I should have removed headers from Insomnia as seen in following images:

Thank you all.

Albertus Geyser

1 Like