Go / Support API / Set a User's Password
Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global_Ref.html">Global Unlock Sample for sample code.
http := chilkat.NewHttp()
var success bool
http.SetBasicAuth(true)
http.SetLogin("login")
http.SetPassword("password")
http.SetRequestHeader("Accept","application/json")
resp := http.QuickRequest("POST","https://example.zendesk.com/api/v2/users/:user_id/password")
if http.LastMethodSuccess() == false {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
return
}
sbResponseBody := chilkat.NewStringBuilder()
resp.GetBodySb(sbResponseBody)
jResp := chilkat.NewJsonObject()
jResp.LoadSb(sbResponseBody)
jResp.SetEmitCompact(false)
fmt.Println("Response Body:")
fmt.Println(*jResp.Emit())
respStatusCode := resp.StatusCode()
fmt.Println("Response Status Code = ", respStatusCode)
if respStatusCode >= 400 {
fmt.Println("Response Header:")
fmt.Println(resp.Header())
fmt.Println("Failed.")
resp.DisposeHttpResponse()
http.DisposeHttp()
sbResponseBody.DisposeStringBuilder()
jResp.DisposeJsonObject()
return
}
resp.DisposeHttpResponse()
http.DisposeHttp()
sbResponseBody.DisposeStringBuilder()
jResp.DisposeJsonObject()
Curl Command
curl -u login:password -X POST
-H "Accept: application/json"
https://example.zendesk.com/api/v2/users/:user_id/password
Postman Collection Item JSON
{
"name": "Set a User's Password",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/users/:user_id/password",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"users",
":user_id",
"password"
],
"variable": [
{
"key": "user_id",
"value": "<integer>"
}
]
},
"description": "An admin can set a user's password only if the setting is enabled in Zendesk Support under **Settings** > **Security** > **Global**. The setting is off by default. Only the account owner can access and change this setting.\n\n#### Allowed For\n\n* Admins\n"
},
"response": [
{
"name": "Success description",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/users/:user_id/password",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"users",
":user_id",
"password"
],
"variable": [
{
"key": "user_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "<string>"
}
]
}