Chilkat Online Tools

Foxpro / Sunshine Conversations API / Set Cookie

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

loHttp.BasicAuth = 1
loHttp.Login = "username"
loHttp.Password = "password"

loResp = loHttp.QuickRequest("POST","https://domain.com/")
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    CANCEL
ENDIF

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

curl -X POST
	-u 'username:password'
https://domain.com/

Postman Collection Item JSON

{
  "name": "Set Cookie",
  "_postman_id": "1477e070-0d3e-4da0-9902-ffcdbcb4bfc0",
  "request": {
    "method": "POST",
    "header": [
    ],
    "url": "{{url}}/v2/apps/{{appId}}/attachments/cookie",
    "description": "With the media JWT retrieved, pass it in the header of the below request as it’s authorization in order to set a cookie in the user’s browser corresponding to the path within the media JWT.\nThe expiration date of this cookie will match the expiration date of the media JWT. This cookie will be needed to visualize a private attachment.\n"
  },
  "response": [
    {
      "id": "a3a2667d-c6ab-43b0-a9d1-62ecddc68667",
      "name": "Ok",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/attachments/cookie",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "attachments",
            "cookie"
          ],
          "variable": [
            {
              "key": "appId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{}"
    }
  ]
}