発注APIの呼び出し例
発注書GETクエリオプション
以下は、発注書APIを使用して希望する結果セットを取得するための使用例です。
このクエリは、以前にエクスポートされていない発注書を含むすべての発注書を返します。
https ://<instance url>/api/purchase_orders? exported = falseこのクエリは、2011年1月1日12:00:00以降に作成されたすべての注文を返します。
https ://<instance url>/api/purchase_orders? created - at [gt] = 2011 -01 -01 T 12:00:00このクエリは、2011年1月1日以降に作成されたすべてのエクスポートされていない発注書を返します。
https ://<instance url>/api/purchase_orders? exportED = false&created_at [gt] = 2011 -01 -1このクエリは、サプライヤーABS Services 1のすべてのエクスポートされていない発注書を返します。
https ://<instance url>/api/purchase_orders? exportED = false&supplier [name] = ABSサービス1このクエリは、発注方法がcXMLに設定されており、バイヤードメイン値に「domain」という単語が含まれているすべてのサプライヤーを返します。
https ://<instance url>/api/suppliers? po - method = cxml&cxml - domain [contains] = domainこのクエリは、cXML請求書発行が許可されており、サプライヤードメイン値のcXML請求書設定に「supplier」という単語が含まれているすべてのサプライヤーを返します。
https ://<instance>[contains ]= supplier
このクエリは、代表連絡先メールアドレスに「coupa.com」が含まれ、市区町村がCharlestonのサプライヤーを返します。
https ://<instance url>/api/suppliers? primary - contact [email] [contains] = coupa.com&primary - address [city] =チャールストンこのクエリは、システム内で5件以上のユーザーレビューがあるすべてのサプライヤーを返します。
https ://<instance url>/api/suppliers? reviews - count [gt] = 5このクエリは、支払方法が「pcard」で、ステータスが「closed」ではないすべての発注書を返します。
https ://<instance url>/api/purchase_orders? payment_method = pcard&status [not_eq] = closedGET発注書
この例では、単一の発注書レコード番号2400をクエリしています
以下のURLに対してGETリクエストを実行しました。
https ://<instance url>/api/purchase_orders/2400または
https ://<instance url>/api/purchase_orders? id = 2400以下は、検索条件に一致したレスポンスの例です。
<?xml version="1.0" encoding="UTF-8"?> <order-headers type="array"> <order-header> <acknowledged-flag type="boolean">false</acknowledged-flag> <created-at type="datetime">2010 -12 -21 T 12:08:43 - 08:00</created-at> <id type="integer">2400</id> <status>issued</status> <transmission-status>sent_via_email</transmission-status> <updated-at type="datetime">-21 T 14:16:03 - 08:00</updated-at> <version type="integer">1</version> <exported type="boolean">false</exported> <attachment type="integer" /> <received type="boolean" /> <custom-field-2 type="string" /> <buyer type="string" /> <custom-field-4 type="string" /> <date type="datetime" /> <project2 type="string">DBA 1</project2> <created-by> <email>upgrade90@coupa.com</email> <employee-number /> <firstname>Coupa</firstname> <id type="integer">1</id> <lastname>Support</lastname> <login>coupasupport</login> </created-by> <email><requisition-header> <id type="integer">1902</id> <requester> upgrade90@coupa.com</email> <employee-number /> <firstname>Coupa</firstname> <id type="integer">1</id> <lastname>Support</lastname> <login>coupasupport</login> </requester> </requisition-header> <ship-to-address> <attention /> <city>Redwood City</city> <id type="integer">1</id> <name nil="true" /> <postal-code>94029</postal-code> <state>CA</state> <street1>250 Sycamore Avenue</street1> <street2 /> <country> <code>US</code> <id type="integer">223</id> <name>米国</name> </country> </ship-to-address> <ship-to-user> <email>upgrade90@coupa.com</email> <employee-number /> <firstname>Coupa</firstname> <id type="integer">1</id> <lastname>Support</lastname> <login>coupasupport</login> </ship-to-user> <supplier> <id type="integer">2</id> <name>ABS Services 1</name> <number>28</number> <primary-contact> <email>ben.mlynash@coupa.com</email> <id type="integer">327</id> <name-additional nil="true" /> <name-family>ロドリゲス</name-family> <name-given><name-fullname nil="true" /> Paul</name-given> <name-prefix nil="true" /> <name-suffix nil="true" /> <notes nil="true" /> <phone-fax> <area-code>232</area-code> <country-code>1</country-code> <extension nil="true" /> <number>2321192</number> </phone-fax> </primary-contact> <primary-address> <attention nil="true" /> <city>Palo Alto</city> <id type="integer">385</id> <name>ABS Services 1</name> <postal-code>94301</postal-code> <state>CA</state> <street1>500 Main St</street1> <street2 /> <country> <code>US</code> <id type="integer">223</id> <name>United States</name> </country> </primary-address> </supplier> <updated-by> <email>upgrade90@coupa.com</email> <employee-number /> <firstname>Coupa</firstname> <id type="integer">1</id> <lastname>Support</lastname> <login>coupasupport</login> </updated-by> <payment-term> <code>Net 45</code> <days-for-discount-payment type="integer" nil="true" /> <days-for-net-payment type="integer" nil="true" /> <discount-rate type="float" nil="true" /> <id type="integer">2</id> </payment-term> <shipping-term> <code>UPS - Ground</code> <id type="integer">1</id> </shipping-term> <attachments /> <order-lines> <order-line> <accounting-total type="decimal">500.00</accounting-total> <created-at type="datetime">2010 -12 -21 T 12:08:43 - 08:00</created-at> <description>Q 4</description> <id type="integer">1325</id> <invoiced type="float">0.00</invoiced> <line-num type="integer">1</line-num> <need-by-date type="datetime">2010 -12 -24 T 00:00:00 - 08:00</need-by-date> <order-header-id type="integer">2400</order-header-id> <price type="decimal">500.00</price> <quantity type="float" /> <received type="float">0.00</received> <source-part-num /> <status>received</status> <sub-line-num type="integer" /> <supp-aux-part-num /> <total type="decimal">500.00</total> <type>OrderAmountLine</type> <updated-at type="datetime">2010 -12 -30 T 13:03:56 - 08:00</updated-at> <version type="integer" /> <options type="string" /> <family type="string" /> <family1 type="string" /> <test-date type="datetime" /> <tax-id type="string" /> <custom-field-2 type="boolean" /> <custom-field-1 type="boolean" /> <buyer type="string" /> <dept type="string" /> <account> <active type="boolean">true</active> <code>01 -100 -8000</code> <id type="integer">26</id> <name>USA - Marketing, Assets</name> <segment-1>01</segment-1> <segment-10 nil="true" /> <segment-11 nil="true" /> <segment-12 nil="true" /> <segment-13 nil="true" /> <segment-14 nil="true" /> <segment-15 nil="true" /> <segment-16 nil="true" /> <segment-17 nil="true" /> <segment-18 nil="true" /> <segment-19 nil="true" /> <segment-2>100</segment-2> <segment-20 nil="true" /> <segment-3>8000</segment-3> <segment-4 nil="true" /> <segment-5 nil="true" /> <segment-6 nil="true" /> <segment-7 nil="true" /> <segment-8 nil="true" /> <segment-9 nil="true" /> <account-type> <id type="integer">2</id> <name>勘定科目表</name> </account-type> </account> <accounting-total-currency> <code>米ドル</code> <id type="integer">1</id> </accounting-total-currency> <currency> <code>米ドル</code> <id type="integer">1</id> </currency> <commodity> <active type="boolean">true</active> <created-at type="datetime">2007 -11 -26 T 16:03:18 Z</created-at> <id type="integer">2</id> <name>事務用品</name> <updated-at type="datetime">2009 -10 -08 T 23:45:03 Z</updated-at> <created-by> <email>bmlynash@gmail.com</email> <employee-number>12</employee-number> <firstname>ボブ</firstname> <id type="integer">33</id> <lastname>Admin</lastname> <login>admin</login> </created-by> <updated-by> <email>bmlynash@gmail.com</email> <employee-number>12</employee-number> <firstname>Bob</firstname> <id type="integer">33</id> <lastname>Admin</lastname> <login>admin</login> </updated-by> <category type="string" /> </commodity> <created-by> <email>upgrade90@coupa.com</email> <employee-number /> <firstname>Coupa</firstname> <id type="integer">1</id> <lastname>Support</lastname> <login>coupasupport</login> </created-by> <supplier> <id type="integer">2</id> <name>ABS Services 1</name> <number>28</number> <primary-contact> <email>ben.mlynash@coupa.com</email> <id type="integer">327</id> <name-additional nil="true" /> <name-family>Rodriguez</name-family> <name-fullname nil="true" /> <name-given>Paul</name-given> <name-prefix nil="true" /> <name-suffix nil="true" /> <notes nil="true" /> <phone-fax> <area-code>232</area-code> <country-code>1</country-code> <extension nil="true" /> <number>2321192</number> </phone-fax> </primary-contact> <primary-address> <attention nil="true" /> <city>パロアルト</city> <id type="integer">385</id> <name>ABSサービス1</name> <postal-code>94301</postal-code> <state>CA</state> <street1>500メインストリート</street1> <street2 /> <country> <code>米国</code> <id type="integer">223</id> <name>米国</name> </country> </primary-address> </supplier> <updated-by> <email>upgrade90@coupa.com</email> <employee-number /> <firstname>Coupa</firstname> <id type="integer">1</id> <lastname>サポート</lastname> <login>クーパスサポート</login> </updated-by> <asset-tags /> <attachments /> </order-line> </order-lines> </order-header> </order-headers>発注書PUT (更新)
概要
当社の発注書APIを使用すると、ヘッダーカスタマーフィールドを更新したり、Coupaで既存の発注書の発注書を閉じたり、キャンセルしたりできます。 また、明細レコードの追加、削除、更新にも対応しています。
この情報を入力できるURLは次のとおりです。 https ://<instance url>/api/purchase_orders/<order id>
成功した要求はHTTP 200 OKを返します。 レスポンスの本文にはたった今更新された請求書が含まれます。
リクエストが失敗すると、HTTP 400 Bad Requestが返されます。 レスポンスの本文にはXML形式の検証エラーが含まれます。
注記
このAPIでは以下のアクションを実行できます。
発注の完了またはキャンセル
次のリクエストで発注書にPUTリクエストを行うと、キャンセルへの変更を試みることができます。
POをキャンセル
<?xml version="1.0" encoding="UTF-8"?> <order-header> <_cancel>true</_cancel> </order-header>同様に、次のリクエストで発注書にPUTリクエストを行って完了済みへの変更を試みることもできます。
発注書を完了
<?xml version="1.0" encoding="UTF-8"?> <order-header> <_close>true</_close> </order-header>どちらのアクションでも、ウェブサイトを介してユーザーによってリクエストされた場合と同様、すべての検証が行われます。 エラーはレスポンス本文で返されます。
発注明細の追加
発注明細は、次のようなリクエストで既存の発注に追加することができます。
発注明細を追加
<?xml version="1.0" encoding="UTF-8"?> <order-header> <order-lines> <order-line> <type>OrderQuantityLine</type> <description>新しい項目の行の説明</description> <quantity>2</quantity> <price>30.33</price> <currency> <code>USD</code> </currency> <account> <code>USA - Development - Consulting</code> <account-type> <name>US Chart Of Accounts</name> </account-type> </account> </order-line> </order-lines> </order-header>明細がすべての検証に合格すると発注書のバージョンが繰り上がり、設定されている場合、サプライヤーは新しいバージョンの発注書を自動的に受け取ります。
発注明細の編集
発注明細要素に明細ID番号を含めると、既存の発注明細を編集できます。
既存の発注明細を編集
<?xml version="1.0" encoding="UTF-8"?> <order-header> <order-lines> <order-line> <id>213</id> <description>更新項目の説明</description> <quantity>5</quantity> <price>35.33</price> <account> <code>USA - Sales - Consulting</code> <account-type> <name>US Chart Of Accounts</name> </account-type> </account> <some-custom-field>更新カスタムフィールドの値</some-custom-field> </order-line> </order-lines> </order-header>変更内容に応じて新しいバージョンの発注書が作成され、サプライヤーに送信されることがあります。 これらの変更には、注文数量、単価、アイテムの変更が含まれます。 アカウントの変更など、その他の変更ではサプライヤーへの再送信が行われない場合があります。
発注明細の削除
削除する明細IDと削除リクエストの両方を発注明細要素に渡すと、既存の発注明細を削除することができます。
発注明細を削除
<?xml version="1.0" encoding="UTF-8"?> <order-header> <order-lines> <order-line> <id>3214</id> <_delete>true</_delete> </order-line> </order-lines> </order-header>この変更により新しい発注書バージョンが作成され、発注書が再送信されます。
既存の発注書に新しい明細を追加する
アカウント情報を含む新しい発注明細の追加。 アカウント情報を含む新しい明細を追加する場合で、特にセグメントの値に特殊文字が含まれている場合は、アカウントコード値と個別のセグメントの送信が推奨されています。
<?xml version="1.0" encoding="UTF-8"?> <order-header> <id>4552</id> <order-lines> <order-line> <type>注文数量ライン</type> <description>テスト</description> <need-by-date>2015 -02 -05 T 00:00:00</need-by-date> <price>20.00</price> <quantity>2.000000</quantity> <account> <code>51110000 - N/A --61 W 2/07001 O 001 -1 -002</code> <segment-1>51110000</segment-1> <segment-2>N/A</segment-2> <segment-3 /> <segment-4>61 W 2/07001 O 001 -1 -002</segment-4> </account> <currency> <code>USD</code> </currency> <commodity> <name>01080001 51236000ビル & C</name> </commodity> <uom> <code>EA</code> </uom> </order-line> </order-lines> </order-header>