Chilkat Online Tools

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

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkBinData.h>
#include <C_CkHttpResponse.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkBinData bdRequestBody;
    HCkHttpResponse resp;

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

    http = CkHttp_Create();

    bdRequestBody = CkBinData_Create();
    success = CkBinData_LoadFile(bdRequestBody,"file");
    if (success != TRUE) {
        printf("Failed to load file\n");
        CkHttp_Dispose(http);
        CkBinData_Dispose(bdRequestBody);
        return;
    }

    CkHttp_SetRequestHeader(http,"Authorization","{{partner_resource_authorization_header}}");

    resp = CkHttp_PBinaryBd(http,"PUT","https://domain.com/",bdRequestBody,"{{partner_resource_mimeType}}",FALSE,FALSE);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkBinData_Dispose(bdRequestBody);
        return;
    }

    printf("%d\n",CkHttpResponse_getStatusCode(resp));
    printf("%s\n",CkHttpResponse_bodyStr(resp));
    CkHttpResponse_Dispose(resp);


    CkHttp_Dispose(http);
    CkBinData_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": [
  ]
}