Chilkat Online Tools

unicodeC / EPC 2.0 - Partner Sandbox - 19.4 November [External] / Stream Resource

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkBinDataW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkBinDataW bdRequestBody;
    HCkHttpResponseW resp;

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

    http = CkHttpW_Create();

    bdRequestBody = CkBinDataW_Create();
    success = CkBinDataW_LoadFile(bdRequestBody,L"file");
    if (success != TRUE) {
        wprintf(L"Failed to load file\n");
        CkHttpW_Dispose(http);
        CkBinDataW_Dispose(bdRequestBody);
        return;
    }

    CkHttpW_SetRequestHeader(http,L"Authorization",L"{{partner_resource_authorization_header}}");

    resp = CkHttpW_PBinaryBd(http,L"PUT",L"https://domain.com/",bdRequestBody,L"{{partner_resource_mimeType}}",FALSE,FALSE);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkBinDataW_Dispose(bdRequestBody);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkBinDataW_Dispose(bdRequestBody);

    }

Curl Command

curl -X PUT
	-H "Authorization: {{partner_resource_authorization_header}}"
	-H "Content-Type: {{partner_resource_mimeType}}"
	--data-binary '@file'
https://domain.com/

Postman Collection Item JSON

{
  "name": "Stream Resource",
  "_postman_id": "42a10928-705a-4438-8ebe-34ff972cc25d",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Authorization",
        "value": "{{partner_resource_authorization_header}}",
        "type": "text"
      },
      {
        "key": "Content-Type",
        "value": "{{partner_resource_mimeType}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "file",
      "file": {
        "src": ""
      }
    },
    "url": "{{partner_resource_location}}"
  },
  "response": [
  ]
}