Chilkat Online Tools

DataFlex / Coupa Postman Collection - OAuth - Master / Create SIM Record against existing Supplier

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Handle hoXml
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vResp
    Handle hoResp
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Use this online tool to generate code from sample XML: Generate Code to Create XML

    // The following XML is sent in the request body.

    // <?xml version="1.0" encoding="utf-8"?>
    // <supplier-information>
    //     <supplier-id>:id</supplier-id>
    //     <status>approved</status>
    //     <name>SIM Company</name>
    //     <exported>true</exported>
    //     <supplier-information-addresses>
    //         <supplier-information-address>
    //             <kind>RTA</kind>
    //             <location-code>001</location-code>
    //             <street-address>59 Bank Avenue</street-address>
    //             <postal-code>15200</postal-code>
    //             <city>Pittsburgh</city>
    //             <state-region>PA</state-region>
    //             <bank-name>Bank Inc.</bank-name>
    //             <bank-account-number>9999325</bank-account-number>
    //             <currency>
    //                 <code>USD</code>
    //             </currency>
    //         </supplier-information-address>
    //         <supplier-information-address>
    //             <kind>RTA</kind>
    //             <location-code>002</location-code>
    //             <street-address>71 Sample Street</street-address>
    //             <postal-code>19100</postal-code>
    //             <city>Philadelphia</city>
    //             <state-region>PA</state-region>
    //             <bank-name>Cash Co.</bank-name>
    //             <bank-account-number>8888325</bank-account-number>
    //             <currency>
    //                 <code>USD</code>
    //             </currency>
    //         </supplier-information-address>
    //     </supplier-information-addresses>
    // </supplier-information>
    // 

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Set ComTag Of hoXml To "supplier-information"
    Send ComUpdateChildContent To hoXml "supplier-id" ":id"
    Send ComUpdateChildContent To hoXml "status" "approved"
    Send ComUpdateChildContent To hoXml "name" "SIM Company"
    Send ComUpdateChildContent To hoXml "exported" "true"
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address|kind" "RTA"
    Send ComUpdateChildContentInt To hoXml "supplier-information-addresses|supplier-information-address|location-code" 001
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address|street-address" "59 Bank Avenue"
    Send ComUpdateChildContentInt To hoXml "supplier-information-addresses|supplier-information-address|postal-code" 15200
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address|city" "Pittsburgh"
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address|state-region" "PA"
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address|bank-name" "Bank Inc."
    Send ComUpdateChildContentInt To hoXml "supplier-information-addresses|supplier-information-address|bank-account-number" 9999325
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address|currency|code" "USD"
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address[1]|kind" "RTA"
    Send ComUpdateChildContentInt To hoXml "supplier-information-addresses|supplier-information-address[1]|location-code" 002
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address[1]|street-address" "71 Sample Street"
    Send ComUpdateChildContentInt To hoXml "supplier-information-addresses|supplier-information-address[1]|postal-code" 19100
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address[1]|city" "Philadelphia"
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address[1]|state-region" "PA"
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address[1]|bank-name" "Cash Co."
    Send ComUpdateChildContentInt To hoXml "supplier-information-addresses|supplier-information-address[1]|bank-account-number" 8888325
    Send ComUpdateChildContent To hoXml "supplier-information-addresses|supplier-information-address[1]|currency|code" "USD"

    // Adds the "Authorization: Bearer <access_token>" header.
    Set ComAuthToken Of hoHttp To "<access_token>"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComGetXmlSb Of hoXml vSbRequestBody To iSuccess

    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComPTextSb Of hoHttp "POST" "https://domain.com/supplier_information/" vSbRequestBody "utf-8" "application/xml" False False To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iTemp1
    Showln iTemp1
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1
    Send Destroy of hoResp


End_Procedure

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-d '<supplier-information>
  <supplier-id>:id</supplier-id>
  <status>approved</status>
  <name>SIM Company</name>
  <exported>true</exported>
  <supplier-information-addresses>
    <supplier-information-address>
        <kind>RTA</kind>
        <location-code>001</location-code>
        <street-address>59 Bank Avenue</street-address>
        <postal-code>15200</postal-code>
        <city>Pittsburgh</city>
        <state-region>PA</state-region>
        <bank-name>Bank Inc.</bank-name>
        <bank-account-number>9999325</bank-account-number>
        <currency>
          <code>USD</code>
        </currency>
    </supplier-information-address>
    <supplier-information-address>
      <kind>RTA</kind>
      <location-code>002</location-code>
      <street-address>71 Sample Street</street-address>
      <postal-code>19100</postal-code>
      <city>Philadelphia</city>
      <state-region>PA</state-region>
      <bank-name>Cash Co.</bank-name>
      <bank-account-number>8888325</bank-account-number>
      <currency>
        <code>USD</code>
      </currency>
    </supplier-information-address>
  </supplier-information-addresses>
</supplier-information>'
https://domain.com/supplier_information/

Postman Collection Item JSON

{
  "name": "Create SIM Record against existing Supplier",
  "request": {
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "<supplier-information>\n  <supplier-id>:id</supplier-id>\n  <status>approved</status>\n  <name>SIM Company</name>\n  <exported>true</exported>\n  <supplier-information-addresses>\n    <supplier-information-address>\n        <kind>RTA</kind>\n        <location-code>001</location-code>\n        <street-address>59 Bank Avenue</street-address>\n        <postal-code>15200</postal-code>\n        <city>Pittsburgh</city>\n        <state-region>PA</state-region>\n        <bank-name>Bank Inc.</bank-name>\n        <bank-account-number>9999325</bank-account-number>\n        <currency>\n          <code>USD</code>\n        </currency>\n    </supplier-information-address>\n    <supplier-information-address>\n      <kind>RTA</kind>\n      <location-code>002</location-code>\n      <street-address>71 Sample Street</street-address>\n      <postal-code>19100</postal-code>\n      <city>Philadelphia</city>\n      <state-region>PA</state-region>\n      <bank-name>Cash Co.</bank-name>\n      <bank-account-number>8888325</bank-account-number>\n      <currency>\n        <code>USD</code>\n      </currency>\n    </supplier-information-address>\n  </supplier-information-addresses>\n</supplier-information>",
      "options": {
        "raw": {
          "language": "xml"
        }
      }
    },
    "url": {
      "raw": "{{URL}}/supplier_information/",
      "host": [
        "{{URL}}"
      ],
      "path": [
        "supplier_information",
        ""
      ]
    },
    "description": "This API is used for creating shell SIM records before importing legacy Suppliers. Status of SIM will be \"approved\" and exported flag will be marked as true."
  },
  "response": [
  ]
}