Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; Use this online tool to generate code from sample JSON: Generate Code to Create JSON
; The following JSON is sent in the request body.
; {
; "name": "update-name",
; "description": "update-description",
; "private": false
; }
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"name","update-name")
CkJsonObject::ckUpdateString(json,"description","update-description")
CkJsonObject::ckUpdateBool(json,"private",0)
; Adds the "Authorization: Bearer <access_token>" header.
CkHttp::setCkAuthToken(http, "<access_token>")
sbRequestBody.i = CkStringBuilder::ckCreate()
If sbRequestBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckEmitSb(json,sbRequestBody)
resp.i = CkHttp::ckPTextSb(http,"PUT","https://api.twitter.com/2/lists/:id",sbRequestBody,"utf-8","application/json",0,0)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
ProcedureReturn
EndIf
Debug Str(CkHttpResponse::ckStatusCode(resp))
Debug CkHttpResponse::ckBodyStr(resp)
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
ProcedureReturn
EndProcedure
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-d '{
"name": "update-name",
"description": "update-description",
"private": false
}'
https://api.twitter.com/2/lists/:id
Postman Collection Item JSON
{
"name": "Update a list",
"request": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"update-name\",\n \"description\": \"update-description\",\n \"private\": false\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.twitter.com/2/lists/:id",
"protocol": "https",
"host": [
"api",
"twitter",
"com"
],
"path": [
"2",
"lists",
":id"
],
"variable": [
{
"key": "id",
"value": null,
"description": "The ID of the List you wish to update the metadata of - the List must be owned by the authenticated user"
}
]
},
"description": "Allows the authenticated user to update a List they own.\n\nFor full details, see the [API reference](https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/put-lists-id) for this endpoint.\n\n[Sign up](https://t.co/signup) for the Twitter API"
},
"response": [
]
}