• 最終編集日時: 29 October 2020

発注書APIコールの例

発注書GETクエリオプション

発注書APIを使用して必要な結果セットをクエリして取得する方法の例を以下に示します。

このクエリは、以前にエクスポートされていないPOのあるすべてのPOを返します。

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
 
このクエリは、発注方法がcXMLに設定されていて、購入者のドメイン値に「ドメイン」という言葉が含まれているすべてのサプライヤーを返します。 

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

このクエリは、支払方法が「Pカード」で、ステータスが終了ではないすべての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(更新)

概要

Coupaの発注書APIを使用すると、ヘッダー顧客フィールドを更新するか、Coupaの既存の発注書のPOを閉じるかキャンセルできます。また、品目レコードの追加、削除、更新もサポートしています。

この情報を入力できるURLは次のとおりです。

  • https://<instance url>/api/purchase_orders/<order id>

​​​​​​成功したリクエストはHTTP 200 OKを返します。回答の本文には、更新されたばかりの請求書が含まれます。

失敗したリクエストはHTTP 400 Bad Requestを返します。応答の本文には、XMLとしてフォーマットされた検証エラーが含まれます。

メモ

このAPIでは以下のアクションを実行できます。

POを完了またはキャンセル

次のリクエストを含むPOにPUTリクエストを作成することで、POをキャンセルに変更できます。

POをキャンセル

<?xml version="1.0" encoding="UTF-8"?>
<order-header>
	 <_cancel>true</_cancel>
</order-header>

同様に、次のリクエストでPOにPUTリクエストを行うことで、POを完了に変更できます。

発注書を終了

<?xml version="1.0" encoding="UTF-8"?>
<order-header>
	 <_close>true</_close>
</order-header> 

両方のアクションは、ウェブサイトを介してユーザーがリクエストを行ったかのように、すべての検証に従います。エラーはすべて返答本文に返されます。

PO品目を追加 

次のような申請により、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番号を注文品目要素に含めることで、既存のPO品目を編集できます。

既存のPO品目を編集

<?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と注文品目要素への削除リクエストの両方を渡すことで、既存の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に新しい品目を追加する

会計を含む新しい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 &amp; C</name>
				 </commodity>
				 <uom>
						<code>EA</code>
				 </uom>
			</order-line>
	 </order-lines>
</order-header>

 

このページに表示されている一部、または全ての内容は、機械翻訳によるものです。ご了承ください。

関連アイテム


Coupa Core API

CoupaのRESTful APIは、お客様のデータをCoupaプラットフォームで読み取り、編集し、統合するための堅牢なアクセスを提供します。

APIの開始

Coupa APIの使用に関する一般情報、およびCSVの使用を検討するタイミング。

OAuth 2.0およびOIDCへの移行

Coupaは従来のAPIキーを廃止し、OAuth 2.0 / OIDCの使用を必要としています。R34以降、新しいAPIキーは発行されず、R35ではAPIキーはサポートされなくなります。

リソース

参照データ、トランザクションデータ、共有リソースなど、オブジェクトのタイプ別にAPIエンドポイントを整理しました。