Chilkat Online Tools

DataFlex / Coupa Postman Collection - OAuth - Master / Create SIM Site using SIM ID in the payload

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-site>
    //     <supplier-information-id>650</supplier-information-id>
    //     <active>true</active>
    //     <addresses>
    //         <address>
    //             <id>689</id>
    //         </address>
    //         <address>
    //             <id>688</id>
    //         </address>
    //     </addresses>
    //     <buyer-hold>false</buyer-hold>
    //     <code>SIM load4 code12</code>
    //     <contacts>
    //         <contact>
    //             <id>519</id>
    //         </contact>
    //     </contacts>
    //     <content-groups/>
    //     <cxml-domain nil="true"/>
    //     <cxml-http-username nil="true"/>
    //     <cxml-identity nil="true"/>
    //     <cxml-protocol nil="true"/>
    //     <cxml-secret nil="true"/>
    //     <cxml-ssl-version nil="true"/>
    //     <cxml-supplier-domain nil="true"/>
    //     <cxml-supplier-identity nil="true"/>
    //     <cxml-url nil="true"/>
    //     <default-locale>en</default-locale>
    //     <disable-cert-verify>false</disable-cert-verify>
    //     <name>SIM load4 site name12</name>
    //     <po-change-method>prompt</po-change-method>
    //     <po-email nil="true"/>
    //     <po-method>prompt</po-method>
    // </supplier-information-site>
    // 

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Set ComTag Of hoXml To "supplier-information-site"
    Send ComUpdateChildContentInt To hoXml "supplier-information-id" 650
    Send ComUpdateChildContent To hoXml "active" "true"
    Send ComUpdateChildContentInt To hoXml "addresses|address|id" 689
    Send ComUpdateChildContentInt To hoXml "addresses|address[1]|id" 688
    Send ComUpdateChildContent To hoXml "buyer-hold" "false"
    Send ComUpdateChildContent To hoXml "code" "SIM load4 code12"
    Send ComUpdateChildContentInt To hoXml "contacts|contact|id" 519
    Send ComUpdateChildContent To hoXml "content-groups" ""
    Get ComUpdateAttrAt Of hoXml "cxml-domain" True "nil" "true" To iSuccess
    Get ComUpdateAttrAt Of hoXml "cxml-http-username" True "nil" "true" To iSuccess
    Get ComUpdateAttrAt Of hoXml "cxml-identity" True "nil" "true" To iSuccess
    Get ComUpdateAttrAt Of hoXml "cxml-protocol" True "nil" "true" To iSuccess
    Get ComUpdateAttrAt Of hoXml "cxml-secret" True "nil" "true" To iSuccess
    Get ComUpdateAttrAt Of hoXml "cxml-ssl-version" True "nil" "true" To iSuccess
    Get ComUpdateAttrAt Of hoXml "cxml-supplier-domain" True "nil" "true" To iSuccess
    Get ComUpdateAttrAt Of hoXml "cxml-supplier-identity" True "nil" "true" To iSuccess
    Get ComUpdateAttrAt Of hoXml "cxml-url" True "nil" "true" To iSuccess
    Send ComUpdateChildContent To hoXml "default-locale" "en"
    Send ComUpdateChildContent To hoXml "disable-cert-verify" "false"
    Send ComUpdateChildContent To hoXml "name" "SIM load4 site name12"
    Send ComUpdateChildContent To hoXml "po-change-method" "prompt"
    Get ComUpdateAttrAt Of hoXml "po-email" True "nil" "true" To iSuccess
    Send ComUpdateChildContent To hoXml "po-method" "prompt"

    // 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" '["id","supplier_information_id","kind","name_given","name_family","email"]}]' 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-site>
    <supplier-information-id>650</supplier-information-id>
    <active>true</active>
    <addresses>
        <address>
            <id>689</id>
        </address>
        <address>
            <id>688</id>
        </address>
    </addresses>
    <buyer-hold>false</buyer-hold>
    <code>SIM load4 code12</code>
    <contacts>
        <contact>
            <id>519</id>
        </contact>
    </contacts>
    <content-groups/>
    <cxml-domain nil="true"/>
    <cxml-http-username nil="true"/>
    <cxml-identity nil="true"/>
    <cxml-protocol nil="true"/>
    <cxml-secret nil="true"/>
    <cxml-ssl-version nil="true"/>
    <cxml-supplier-domain nil="true"/>
    <cxml-supplier-identity nil="true"/>
    <cxml-url nil="true"/>
    <default-locale>en</default-locale>
    <disable-cert-verify>false</disable-cert-verify>
    <name>SIM load4 site name12</name>
    <po-change-method>prompt</po-change-method>
    <po-email nil="true"/>
    <po-method>prompt</po-method>
</supplier-information-site>'
https://domain.com/supplier_information_sites?fields=["id","name","code","supplier_information_id",{"addresses": ["id","supplier_information_id","kind","location_code","address_name","street_address","street_address2","city","postal_code","state",{"country": ["id","code","name"]},{"custom_fields": {}}]},{"contacts": ["id","supplier_information_id","kind","name_given","name_family","email"]}]

Postman Collection Item JSON

{
  "name": "Create SIM Site using SIM ID in the payload",
  "request": {
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "<supplier-information-site>\n    <supplier-information-id>650</supplier-information-id>\n    <active>true</active>\n    <addresses>\n        <address>\n            <id>689</id>\n        </address>\n        <address>\n            <id>688</id>\n        </address>\n    </addresses>\n    <buyer-hold>false</buyer-hold>\n    <code>SIM load4 code12</code>\n    <contacts>\n        <contact>\n            <id>519</id>\n        </contact>\n    </contacts>\n    <content-groups/>\n    <cxml-domain nil=\"true\"/>\n    <cxml-http-username nil=\"true\"/>\n    <cxml-identity nil=\"true\"/>\n    <cxml-protocol nil=\"true\"/>\n    <cxml-secret nil=\"true\"/>\n    <cxml-ssl-version nil=\"true\"/>\n    <cxml-supplier-domain nil=\"true\"/>\n    <cxml-supplier-identity nil=\"true\"/>\n    <cxml-url nil=\"true\"/>\n    <default-locale>en</default-locale>\n    <disable-cert-verify>false</disable-cert-verify>\n    <name>SIM load4 site name12</name>\n    <po-change-method>prompt</po-change-method>\n    <po-email nil=\"true\"/>\n    <po-method>prompt</po-method>\n</supplier-information-site>",
      "options": {
        "raw": {
          "language": "xml"
        }
      }
    },
    "url": {
      "raw": "{{URL}}/supplier_information_sites?fields=[\"id\",\"name\",\"code\",\"supplier_information_id\",{\"addresses\": [\"id\",\"supplier_information_id\",\"kind\",\"location_code\",\"address_name\",\"street_address\",\"street_address2\",\"city\",\"postal_code\",\"state\",{\"country\": [\"id\",\"code\",\"name\"]},{\"custom_fields\": {}}]},{\"contacts\": [\"id\",\"supplier_information_id\",\"kind\",\"name_given\",\"name_family\",\"email\"]}]",
      "host": [
        "{{URL}}"
      ],
      "path": [
        "supplier_information_sites"
      ],
      "query": [
        {
          "key": "fields",
          "value": "[\"id\",\"name\",\"code\",\"supplier_information_id\",{\"addresses\": [\"id\",\"supplier_information_id\",\"kind\",\"location_code\",\"address_name\",\"street_address\",\"street_address2\",\"city\",\"postal_code\",\"state\",{\"country\": [\"id\",\"code\",\"name\"]},{\"custom_fields\": {}}]},{\"contacts\": [\"id\",\"supplier_information_id\",\"kind\",\"name_given\",\"name_family\",\"email\"]}]"
        }
      ]
    }
  },
  "response": [
  ]
}