Sample code for 30+ languages & platforms
C

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 C Downloads

C
#include <C_CkHttp.h>
#include <C_CkXml.h>
#include <C_CkHttpResponse.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttp http;
    HCkXml xml;
    const char *httpRequestBody;
    HCkHttpResponse resp;
    HCkXml xmlResponse;

    success = FALSE;

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

    http = CkHttp_Create();

    // Set the "Accept" header to tell the web server that we'll accept an XML response.
    CkHttp_putAccept(http,"application/xml");

    // Tell Chilkat to cache any received cookies to files in a particular directory
    CkHttp_putCookieDir(http,"c:/qa_data/cookies");
    CkHttp_putSaveCookies(http,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.
    CkHttp_putSendCookies(http,TRUE);

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

    httpRequestBody = CkXml_getXml(xml);
    resp = CkHttpResponse_Create();
    success = CkHttp_HttpStr(http,"POST","http://integration.winwebconnect.com/api/v1/Awb",httpRequestBody,"utf-8","application/xml",resp);
    if (success == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkXml_Dispose(xml);
        CkHttpResponse_Dispose(resp);
        return;
    }

    xmlResponse = CkXml_Create();
    CkXml_LoadXml(xmlResponse,CkHttpResponse_bodyStr(resp));

    // See below for an example XML response body.
    printf("Response Body:\n");
    printf("%s\n",CkXml_getXml(xmlResponse));
    printf("---\n");

    printf("Response Header:\n");
    printf("%s\n",CkHttpResponse_header(resp));
    printf("Success.\n");


    CkHttp_Dispose(http);
    CkXml_Dispose(xml);
    CkHttpResponse_Dispose(resp);
    CkXml_Dispose(xmlResponse);

    }