注文書APIの呼び出し例
このページは機械翻訳を使用して翻訳されています。
発注書のGETクエリオプション
発注書APIを使用して必要な結果セットをクエリして取得する方法の例を以下に示します。
このクエリは、これまでにエクスポートされていないPO付きのすべてのPOSを返します。
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-01T12:00:00
このクエリは、2011年1月1日以降に作成されたすべてのエクスポートされていないPOを返します。
https://<instance url>/api/purchase_orders?exported=false&created_at[gt]=2011-01-1
このクエリは、サプライヤーABSサービス1のすべての非エクスポートPOを返します。
https://<instance url>/api/purchase_orders?exported=false&supplier[name]=ABS Services 1
このクエリは、POメソッドがcXMLに設定されていて、購入者のドメイン値に "domain"という単語が含まれているすべてのサプライヤーを返します。
https://<instance url>/api/suppliers?po-method=cxml&cxml-domain[contains]=domain
このクエリは、cXML請求を許可され、サプライヤードメイン値のcXML請求書設定に「サプライヤー」という単語が含まれているすべてのサプライヤーを返します。
https://<instance>.coupahost.com/api/suppliers?allow-cxml-invoicing=true&cxml-supplier-domain[contains]=supplier
このクエリは、主要連絡先メールに値「coupa.com」と市がチャールストンであるサプライヤーの住所が含まれているすべてのサプライヤーを返します。
https://<instance url>/api/suppliers?primary-contact[email][contains]=coupa.com&primary-address[city]=Charleston
このクエリは、システムに少なくとも5つのユーザーレビューを持つすべてのサプライヤーを返します。
https://<instance url>/api/suppliers?reviews-count[gt]=5
このクエリは、支払方法が「pcard」で、ステータスが完了ではないすべてのPOを返します。
https://<instance url>/api/purchase_orders?payment_method=pcard&status[not_eq]=closed
発注書を取得
この例では、単一の発注書レコード番号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-21T12: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">2010-12-21T14: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">DBA1</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> <requisition-header> <id type="integer">1902</id> <requester> <email>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>United States</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>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>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-21T12:08:43-08:00</created-at> <description>legal services for Q4</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-24T00: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-30T13: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>Chart of Accounts</name> </account-type> </account> <accounting-total-currency> <code>USD</code> <id type="integer">1</id> </accounting-total-currency> <currency> <code>USD</code> <id type="integer">1</id> </currency> <commodity> <active type="boolean">true</active> <created-at type="datetime">2007-11-26T16:03:18Z</created-at> <id type="integer">2</id> <name>Office Supplies</name> <updated-at type="datetime">2009-10-08T23:45:03Z</updated-at> <created-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> </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>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> <asset-tags /> <attachments /> </order-line> </order-lines> </order-header> </order-headers>
発注書PUT(更新)
概要
当社の発注書APIを使用すると、ヘッダー顧客フィールドを更新したり、Coupaの既存の発注書のPOを終了またはキャンセルしたりできます。ラインレコードの追加、削除、更新もサポートしています。
これは、この情報をPUTできるURLです。
https://<instance url>/api/purchase_orders/<order id>
成功したリクエストはHTTP 200 OKを返します。返答の本文には、更新されたばかりのインボイスが含まれます。
失敗した要求はHTTP 400 Bad Requestを返します。応答の本文には、XML形式の検証エラーが含まれます。
メモ
このAPIを使用すると、以下のアクションを実行できます。
POを閉じるまたはキャンセル
POは、次のリクエストでPOにPUTリクエストを行うことで、キャンセルに変更することができます。
POをキャンセル
<?xml version="1.0" encoding="UTF-8"?> <order-header> <_cancel>true</_cancel> </order-header>
同様に、POは、次のリクエストでPOにPUTリクエストを送信することで、完了に変更することを試みることができます。
発注書を終了
<?xml version="1.0" encoding="UTF-8"?> <order-header> <_close>true</_close> </order-header>
リクエストがウェブサイトを介してユーザーによって行われたかのように、両方のアクションはすべての検証に従います。エラーがあればレスポンスボディで返されます。
PO明細を追加
次のような要求により、PO明細を既存のPOに追加できます。
発注品目を追加
<?xml version="1.0" encoding="UTF-8"?> <order-header> <order-lines> <order-line> <type>OrderQuantityLine</type> <description>Line description of the new item</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>
行がすべての検証に合格すると、POバージョンが増加し、設定されている場合、サプライヤーはPOの新しいバージョンを自動的に受け取ります。
PO品目を編集
注文品目要素に品目ID番号を含めることで、既存の発注品目を編集できます。
既存の発注書項目を編集
<?xml version="1.0" encoding="UTF-8"?> <order-header> <order-lines> <order-line> <id>213</id> <description>Update Description of Item</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>Update Custom field value</some-custom-field> </order-line> </order-lines> </order-header>
行われた変更に応じて、POの新しいバージョンが作成され、サプライヤーに送信されます。これらの変更には、注文数量、単価、またはアイテムの変更が含まれます。アカウントの変更など、その他の変更によってサプライヤーへの再送信がトリガーされない場合があります。
PO品目を削除
削除するラインIDと削除リクエストの両方をorder-line要素に渡すことで、既存のPOラインを削除できます。
PO品目を削除
<?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>
この変更により、新しいPOバージョンが作成され、POが再送信されます。
既存の発注書に新しい項目を追加する
会計を含む新規PO品目を追加する。勘定科目情報を含む新しい行を追加する場合、特にセグメントの値に特殊文字が含まれている場合は、勘定科目コード値と個々のセグメントを送信することをお勧めします。
<?xml version="1.0" encoding="UTF-8"?> <order-header> <id>4552</id> <order-lines> <order-line> <type>OrderQuantityLine</type> <description>test</description> <need-by-date>2015-02-05T00:00:00</need-by-date> <price>20.00</price> <quantity>2.000000</quantity> <account> <code>51110000-N/A--61W2/07001O001-1-002</code> <segment-1>51110000</segment-1> <segment-2>N/A</segment-2> <segment-3 /> <segment-4>61W2/07001O001-1-002</segment-4> </account> <currency> <code>USD</code> </currency> <commodity> <name>01080001 51236000 BUILDING & C</name> </commodity> <uom> <code>EA</code> </uom> </order-line> </order-lines> </order-header>