Chilkat Online Tools

Xojo / Sunshine Conversations API / Set Cookie

Back to Collection Items

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

Dim http As New Chilkat.Http
Dim success As Boolean

http.BasicAuth = True
http.Login = "username"
http.Password = "password"

Dim resp As Chilkat.HttpResponse
resp = http.QuickRequest("POST","https://domain.com/")
If (http.LastMethodSuccess = False) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

Dim sbResponseBody As New Chilkat.StringBuilder
success = resp.GetBodySb(sbResponseBody)

Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())

Dim respStatusCode As Int32
respStatusCode = resp.StatusCode
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
    System.DebugLog("Response Header:")
    System.DebugLog(resp.Header)
    System.DebugLog("Failed.")

    Return
End If

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": "{}"
    }
  ]
}