Chilkat Online Tools

Swift3 / DocuSign REST API / Updates the user profile image for a specified user.

Back to Collection Items

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

    let http = CkoHttp()!
    var success: Bool

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {}

    let json = CkoJsonObject()!

    http.setRequestHeader("Content-Type", value: "image/gif")
    // Adds the "Authorization: Bearer {{accessToken}}" header.
    http.authToken = "{{accessToken}}"
    http.setRequestHeader("Accept", value: "application/json")

    let sbRequestBody = CkoStringBuilder()!
    json.emitSb(sbRequestBody)

    var resp: CkoHttpResponse? = http.pTextSb("PUT", url: "https://domain.com/v2.1/accounts/{{accountId}}/users/{{userId}}/profile/image", textData: sbRequestBody, charset: "utf-8", contentType: "image/gif", md5: false, gzip: false)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    print("\(resp!.statusCode.intValue)")
    print("\(resp!.bodyStr!)")
    resp = nil

}

Curl Command

curl -X PUT
	-H "Accept: application/json"
	-H "Content-Type: image/gif"
	-H "Authorization: Bearer {{accessToken}}"
	-d '{}'
https://domain.com/v2.1/accounts/{{accountId}}/users/{{userId}}/profile/image

Postman Collection Item JSON

{
  "name": "Updates the user profile image for a specified user.",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "Content-Type",
        "value": "image/gif"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{}"
    },
    "url": {
      "raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/users/{{userId}}/profile/image",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2.1",
        "accounts",
        "{{accountId}}",
        "users",
        "{{userId}}",
        "profile",
        "image"
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "{{accountId}}"
        },
        {
          "key": "userId",
          "value": "{{userId}}"
        }
      ]
    },
    "description": "Updates the user profile image by uploading an image to the user profile.\n\nThe supported image formats are: gif, png, jpeg, and bmp. The file must be less than 200K. For best viewing results, DocuSign recommends that the image is no more than 79 pixels wide and high."
  },
  "response": [
  ]
}