Sample code for 30+ languages & platforms
DataFlex

WIN Air Freight - Send New Pouch Request

See more HTTP Misc Examples

Sends a "POST /api/v1/Awb" to send a new pouch request.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Handle hoXml
    String sHttpRequestBody
    Variant vResp
    Handle hoResp
    Handle hoXmlResponse
    String sTemp1

    Move False To iSuccess

    // This example assumes the Chilkat HTTP 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

    // Set the "Accept" header to tell the web server that we'll accept an XML response.
    Set ComAccept Of hoHttp To "application/xml"

    // Tell Chilkat to cache any received cookies to files in a particular directory
    Set ComCookieDir Of hoHttp To "c:/qa_data/cookies"
    Set ComSaveCookies Of hoHttp To True

    // Also tell Chilkat to load and send matching cookies from the CookieDir.
    // The authToken cookie is first obtained in the login request. Each subsequent
    // request sends the authToken cookie and saves the new authToken cookie to the CookieDir.
    Set ComSendCookies Of hoHttp To True

    // Build out XML pouch request...
    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Set ComTag Of hoXml To "PouchDTO"
    Send ComUpdateChildContent To hoXml "Mawb|AwbID" ""
    Send ComUpdateChildContent To hoXml "Mawb|AwbNumber" "001-12312123"
    Send ComUpdateChildContent To hoXml "Mawb|AwbStatus" "D"
    Send ComUpdateChildContent To hoXml "Mawb|eAWB" "false"
    Send ComUpdateChildContent To hoXml "Mawb|WithPaper" "false"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|WinID" "444444"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|AccountNumber" "12345"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Name" "AABC SHIPPING & PACKAGING, INC."
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Phone" "111-222-3334"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Fax" "222-111-3334"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Email" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Address|Line1" "500 HARBOR DRIVE"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Address|Line2" "SUITE B1211"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Address|Place" "BEAUFORT"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Address|PostalCode" "28516"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Address|StateProvince" "NC"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Address|Country|Code" "US"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Shipper|Address|Country|Name" "U.S.A."
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|WinID" "0"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|AccountNumber" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Name" "DELTA MANUFACTURING"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Phone" "444-555-3333"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Fax" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Email" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Address|Line1" "185 RUE LAMANDE"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Address|Line2" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Address|Place" "PARIS"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Address|PostalCode" "75017"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Address|StateProvince" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Address|Country|Code" "FR"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Consignee|Address|Country|Name" "FRANCE"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|WinID" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|AccountNumber" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Name" "AABC SHIPPING, INC."
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Phone" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Fax" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Email" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Address|Line1" "110 FARA WAY"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Address|Line2" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Address|Place" "OZ"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Address|PostalCode" "11222"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Address|StateProvince" "NY"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Address|Country|Code" "US"
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Notify|Address|Country|Name" "U.S.A."
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Agent|WinID" ""
    Send ComUpdateChildContent To hoXml "Mawb|Parties|Agent|AccountNumber" "FACCT#1234"
    Send ComUpdateChildContent To hoXml "Mawb|Accounting|Identifier" "GEN"
    Send ComUpdateChildContent To hoXml "Mawb|Accounting|Information" "SARFWER"
    Send ComUpdateChildContent To hoXml "Mawb|Accounting|Identifier" "MCO"
    Send ComUpdateChildContent To hoXml "Mawb|Accounting|Information" "WERWERWER"
    Send ComUpdateChildContent To hoXml "Mawb|ShipmentReference|ReferenceNumber" "ZDFASF"
    Send ComUpdateChildContent To hoXml "Mawb|ShipmentReference|AdditionalInformation" "ZDFASF"
    Send ComUpdateChildContent To hoXml "Mawb|RoutingDetails|FromAirportCode" "EWN"
    Send ComUpdateChildContent To hoXml "Mawb|RoutingDetails|ToAirportCode" "LON"
    Send ComUpdateChildContent To hoXml "Mawb|RoutingDetails|CarrierCode" "AA"
    Send ComUpdateChildContent To hoXml "Mawb|RoutingDetails|FlightNumber" "N123"
    Send ComUpdateChildContent To hoXml "Mawb|RoutingDetails|FlightDate" "2016-11-30T00:00:00"
    Send ComUpdateChildContent To hoXml "Mawb|ChargesDeclaration|CurrencyCode" "USD"
    Send ComUpdateChildContent To hoXml "Mawb|ChargesDeclaration|ChargeCode" "PP"
    Send ComUpdateChildContent To hoXml "Mawb|ChargesDeclaration|WeightOrValuation" "P"
    Send ComUpdateChildContent To hoXml "Mawb|ChargesDeclaration|Other" "P"
    Send ComUpdateChildContent To hoXml "Mawb|ChargesDeclaration|ValuesForCarriage" "1300.00"
    Send ComUpdateChildContent To hoXml "Mawb|ChargesDeclaration|ValuesForCustoms" "12000.00"
    Send ComUpdateChildContent To hoXml "Mawb|ChargesDeclaration|ValuesForInsurance" "11000.00"
    Send ComUpdateChildContent To hoXml "Mawb|Handling|SpecialServiceInformation" "Please Notify Consigneetestwwwww"
    Send ComUpdateChildContent To hoXml "Mawb|Handling|OtherServiceInformation" ""
    Send ComUpdateChildContent To hoXml "Mawb|Handling|SCI" ""
    Send ComUpdateChildContent To hoXml "Mawb|Handling|SpecialHandling|Code" "AOG"
    Send ComUpdateChildContent To hoXml "Mawb|Handling|SpecialHandling|Code" "ATT"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|NumberOfPieces" "12"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|GrossWeight|Value" "244.70"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|GrossWeight|UOM" "L"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|SLAC" "12"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|RateClassCode" "N"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|CommodityItemNumber" ""
    Send ComUpdateChildContent To hoXml "Mawb|Rates|ChargeableWeight" "245.0"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|RateOrCharge" "8.00"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|ChargeAmount" "1960.00"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|NatureAndQuantityOfGoods" "CONSOLIDATION PER ATTACHED MANIFEST."
    Send ComUpdateChildContent To hoXml "Mawb|Rates|Dims|Pcs" "12"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|Dims|Length" "4"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|Dims|Width" "8"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|Dims|Height" "4"
    Send ComUpdateChildContent To hoXml "Mawb|Rates|Dims|UOM" "CMT"
    Send ComUpdateChildContent To hoXml "Mawb|ChargesSummary|WeightCharge" "1960.00"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|Description" "AW"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|Amount" "123.00"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|ChargeIdentifier" "C"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|PrepaidCollect" "C"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|Description" "FC"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|Amount" "55.00"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|ChargeIdentifier" "A"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|PrepaidCollect" "P"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|Description" "FC"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|Amount" "101.00"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|ChargeIdentifier" "C"
    Send ComUpdateChildContent To hoXml "Mawb|OtherCharges|PrepaidCollect" "C"
    Send ComUpdateChildContent To hoXml "Mawb|EmailNotifications|Name" ""
    Send ComUpdateChildContent To hoXml "Mawb|EmailNotifications|Email" ""
    Send ComUpdateChildContent To hoXml "Mawb|EmailNotifications|Name" ""
    Send ComUpdateChildContent To hoXml "Mawb|EmailNotifications|Email" ""
    Send ComUpdateChildContent To hoXml "Mawb|EmailNotifications|Name" ""
    Send ComUpdateChildContent To hoXml "Mawb|EmailNotifications|Email" ""
    Send ComUpdateChildContent To hoXml "Mawb|EmailNotifications|Name" ""
    Send ComUpdateChildContent To hoXml "Mawb|EmailNotifications|Email" ""
    Send ComUpdateChildContent To hoXml "Mawb|Execution|Date" "2015-08-07T00:00:00"
    Send ComUpdateChildContent To hoXml "Mawb|Execution|Place" "OZ NY"
    Send ComUpdateChildContent To hoXml "Mawb|Execution|ShipperSignature" "OAS FREIGHT FORWARDE"
    Send ComUpdateChildContent To hoXml "Mawb|Execution|CarrierSignature" "OAS FREIGHT FORWARDE"
    Send ComUpdateChildContent To hoXml "Hawbs|AwbNumber" "001-12312123"
    Send ComUpdateChildContent To hoXml "Hawbs|HawbNumber" "CGL201107-27"
    Send ComUpdateChildContent To hoXml "Hawbs|HawbStatus" "D"
    Send ComUpdateChildContent To hoXml "Hawbs|NumberOfPieces" "12"
    Send ComUpdateChildContent To hoXml "Hawbs|GrossWeight|Value" "244.70"
    Send ComUpdateChildContent To hoXml "Hawbs|GrossWeight|UOM" "K"
    Send ComUpdateChildContent To hoXml "Hawbs|Locations|PortOfOrigin|Code" "EWN"
    Send ComUpdateChildContent To hoXml "Hawbs|Locations|PortOfDestination|Code" "LON"
    Send ComUpdateChildContent To hoXml "Hawbs|Commodity" "HWB #: CGL20110"
    Send ComUpdateChildContent To hoXml "Hawbs|SLAC" "12"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Name" "ABC SHIPPNG AGAIN"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Phone" "111-222-3333"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Fax" ""
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Email" ""
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Address|Line1" "100 MAIN STREET"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Address|Place" "OZ"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Address|PostalCode" "ZIP"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Address|StateProvince" "NY"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Shipper|Address|Country|Code" "US"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Name" "AABC SHIPPING & PACKAGING, INC."
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Phone" "111-222-3334"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Fax" "222-111-3334"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Email" ""
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Address|Line1" "500 HARBOR DRIVE"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Address|Place" "BEAUFORT"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Address|PostalCode" "28516"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Address|StateProvince" "NC"
    Send ComUpdateChildContent To hoXml "Hawbs|Parties|Consignee|Address|Country|Code" "US"
    Set ComEmitXmlDecl Of hoXml To False

    Get ComGetXml Of hoXml To sHttpRequestBody
    Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
    If (Not(IsComObjectCreated(hoResp))) Begin
        Send CreateComObject of hoResp
    End
    Get pvComObject of hoResp to vResp
    Get ComHttpStr Of hoHttp "POST" "http://integration.winwebconnect.com/api/v1/Awb" sHttpRequestBody "utf-8" "application/xml" vResp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatXml)) To hoXmlResponse
    If (Not(IsComObjectCreated(hoXmlResponse))) Begin
        Send CreateComObject of hoXmlResponse
    End
    Get ComBodyStr Of hoResp To sTemp1
    Get ComLoadXml Of hoXmlResponse sTemp1 To iSuccess

    // See below for an example XML response body.
    Showln "Response Body:"
    Get ComGetXml Of hoXmlResponse To sTemp1
    Showln sTemp1
    Showln "---"

    Showln "Response Header:"
    Get ComHeader Of hoResp To sTemp1
    Showln sTemp1
    Showln "Success."


End_Procedure