Votes
Votes represents positive and negative opinions of users aboutarticles,article comments,postsorpost comments.
JSON format
Votes are represented as JSON objects with the following properties:
Name | Type | Read-only | Mandatory | Description |
---|---|---|---|---|
created_at | string | true | false | The time at which the vote was created |
id | integer | true | false | Automatically assigned when the vote is created |
item_id | integer | true | false | The id of the item for which this vote was cast |
item_type | string | true | false | The type of the item. Can be "Article", "Comment", "Post" or "PostComment" |
updated_at | string | true | false | The time at which the vote was last updated |
url | string | true | false | The API url of this vote |
user_id | integer | true | false | The id of the user who cast this vote |
value | integer | false | true | The value of the vote |
Example
{
"created_at":"2012-04-04T09:14:57Z",
"id":1635,
"item_id":65466,
"item_type":"Article",
"user_id":3465,
"value":1
}
List Votes
GET /api/v2/help_center/users/{user_id}/votes
GET /api/v2/help_center/{locale}/articles/{article_id}/votes
GET /api/v2/help_center/{locale}/articles/{article_id}/comments/{comment_id}/votes
GET /api/v2/community/posts/{post_id}/votes
GET /api/v2/community/posts/{post_id}/comments/{comment_id}/votes
Lists all votes cast by a given user, or all votes cast by all users for a given article, article comment, post, or post comment.
To list only your own votes, specifyme
as the user id.
The{locale}
for article and article comment votes is required only for end users. Admins and agents can omit it.
Allowed for
- Agents
- 最终用户
Sideloads
The following sideloads are supported:
Name | Will sideload |
---|---|
users | authors |
articles | articles |
translations | translations of any sideloaded articles |
posts | posts |
comments | comments |
Note that you must sideloadarticles
in order to sideloadtranslations
.
On requests to the/api/v2/help_center/users/{user_id}/votes.json
endpoint, article comments must be sideloaded usingarticle_comments
. Thecomments
sideload will only return community comments.
You can also use different URL to perform this operation
Resource | URL | Required parameters |
---|---|---|
Article | /api/v2/help_center{/locale}/articles/{article_id}/votes |
article_id : The Id of the Article |
Comment | /api/v2/help_center{/locale}/articles/{article_id}/comments/{comment_id}/votes |
article_id : The Id of the Article,comment_id : The ID of the comment |
Post | /api/v2/help_center/posts/{post_id}/votes |
post_id : The Id of the Post |
Post Comment | /api/v2/community/posts/{post_id}/comments/{post_comment_id}/votes |
post_id : The Id of the Post,post_comment_id : The ID of the post comment |
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
user_id | integer | Path | true | The unique ID of the user |
Code Samples
旋度
旋度https://{subdomain}.zendesk.com/api/v2/help_center/users/{user_id}/votes.json\
-v -u{email_address}:{password}
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://support.zendesk.com/api/v2/help_center/users/1234/votes"
method:="GET"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add("Content-Type","application/json")
req.Header.Add("Authorization","Basic
" )// Base64 encoded "username:password"client:=&http.Client{}
res,err:=client.Do(req)
iferr!=nil{
fmt.Println(err)
return
}
deferres.Body.Close()
body,err:=io.ReadAll(res.Body)
iferr!=nil{
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
importcom.squareup.okhttp.*;
OkHttpClientclient=newOkHttpClient();
HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://support.zendesk.com/api/v2/help_center/users/1234/votes")
.newBuilder();
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("GET",null)
.addHeader("Content-Type","application/json")
.addHeader("Authorization",Credentials.basic("your-email","your-password"))
.build();
Responseresponse=client.newCall(request).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'GET',
url:'https://support.zendesk.com/api/v2/help_center/users/1234/votes',
headers:{
'Content-Type':'application/json',
'Authorization':'Basic
' ,// Base64 encoded "username:password"},
};
axios(config)
.then(function(response){
console.log(JSON.stringify(response.data));
})
.catch(function(error){
console.log(error);
});
Python
importrequests
url="https://support.zendesk.com/api/v2/help_center/users/1234/votes"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"GET",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://support.zendesk.com/api/v2/help_center/users/1234/votes")
request=Net::HTTP::Get.new(uri,"Content-Type":"application/json")
request.basic_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"votes":[
{
"id":35467,
"user_id":888887,
"value":-1
}
]
}
Show Vote
GET /api/v2/help_center/votes/{vote_id}
Allowed for
- Agents
- 最终用户
Sideloads
The following sideloads are supported:
Name | Will sideload |
---|---|
users | authors |
articles | articles |
translations | translations of any sideloaded articles |
posts | posts |
comments | comments |
Note that you must sideloadarticles
in order to sideloadtranslations
.
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
vote_id | integer | Path | true | The unique ID of the vote |
Code Samples
旋度
旋度https://{subdomain}.zendesk.com/api/v2/help_center/votes/{vote_id}.json\
-v -u{email_address}:{password}
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://support.zendesk.com/api/v2/help_center/votes/35467"
method:="GET"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add("Content-Type","application/json")
req.Header.Add("Authorization","Basic
" )// Base64 encoded "username:password"client:=&http.Client{}
res,err:=client.Do(req)
iferr!=nil{
fmt.Println(err)
return
}
deferres.Body.Close()
body,err:=io.ReadAll(res.Body)
iferr!=nil{
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
importcom.squareup.okhttp.*;
OkHttpClientclient=newOkHttpClient();
HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://support.zendesk.com/api/v2/help_center/votes/35467")
.newBuilder();
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("GET",null)
.addHeader("Content-Type","application/json")
.addHeader("Authorization",Credentials.basic("your-email","your-password"))
.build();
Responseresponse=client.newCall(request).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'GET',
url:'https://support.zendesk.com/api/v2/help_center/votes/35467',
headers:{
'Content-Type':'application/json',
'Authorization':'Basic
' ,// Base64 encoded "username:password"},
};
axios(config)
.then(function(response){
console.log(JSON.stringify(response.data));
})
.catch(function(error){
console.log(error);
});
Python
importrequests
url="https://support.zendesk.com/api/v2/help_center/votes/35467"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"GET",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://support.zendesk.com/api/v2/help_center/votes/35467")
request=Net::HTTP::Get.new(uri,"Content-Type":"application/json")
request.basic_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"vote":{
"id":35467,
"user_id":888887,
"value":-1
}
}
Create Vote
POST /api/v2/help_center{/locale}/articles/{article_id}/up
POST /api/v2/help_center/articles/{article_id}/down
POST /api/v2/help_center/articles/{article_id}/comments/{comment_id}/up
POST /api/v2/help_center/articles/{article_id}/comments/{comment_id}/down
POST /api/v2/community/posts/{post_id}/up
POST /api/v2/community/posts/{post_id}/down
POST /api/v2/community/posts/{post_id}/comments/{comment_id}/up
POST /api/v2/community/posts/{post_id}/comments/{comment_id}/down
Creates an up or down vote for a givenarticle,article comment,post, orpost comment. If a vote already exists for the source object, it's updated.
Allowed for
- 最终用户
Agents with the Help Center manager role can optionally supply avote
object containing auser_id
value. If provided, the vote will be cast by the user associated withuser_id
.
Agents with the Help Center manager role can also specifycreated_at
as part of thevote
object. If it is not providedcreated_at
is set to the current time.
You can also use different URL to perform this operation, depending on the object you want to vote:
Resource | Vote | URL | Required parameters |
---|---|---|---|
Article | Down | /api/v2/help_center/articles/{article_id}/down |
article_id : The Id of the Article |
Comment | Up | / api / v2 / help_center /文章/ {article_id} /评论/{comment_id}/up |
article_id : The Id of the Article,comment_id : The ID of the comment |
Comment | Down | / api / v2 / help_center /文章/ {article_id} /评论/{comment_id}/down |
article_id : The Id of the Article,comment_id : The ID of the comment |
Post | Up | /api/v2/help_center/posts/{post_id}/up |
post_id : The Id of the Post |
Post | Down | /api/v2/help_center/posts/{post_id}/down |
post_id : The Id of the Post |
Post Comment | Up | /api/v2/community/posts/{post_id}/comments/{post_comment_id}/up |
post_id : The Id of the Post,post_comment_id : The ID of the post comment |
Post Comment | Down | /api/v2/community/posts/{post_id}/comments/{post_comment_id}/down |
post_id : The Id of the Post,post_comment_id : The ID of the post comment |
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
article_id | integer | Path | true | The unique ID of the article |
locale | string | Path | false | The locale the item is displayed in |
Code Samples
旋度
旋度https://{subdomain}.zendesk.com/api/v2/help_center/articles/{article_id}/up.json\
-v -u{email_address}:{password}-X POST -H"Content-Type: application/json"
旋度https://{subdomain}.zendesk.com/api/v2/help_center/articles/{article_id}/comments/{comment_id}/up.json\
-v -u{email_address}:{password}-X POST -H"Content-Type: application/json"
旋度https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/up.json\
-v -u{email_address}:{password}-X POST -H"Content-Type: application/json"
旋度https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments/{post_comment_id}/up.json\
-v -u{email_address}:{password}-X POST -H"Content-Type: application/json"
旋度https://{subdomain}.zendesk.com/api/v2/help_center/articles/{article_id}/down.json\
-d'{"vote": {"user_id": 10056}}'\
-v -u{email_address}:{password}-X POST -H"Content-Type: application/json"
旋度https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/down.json\
-d'{"vote": {"user_id": 10056}}'\
-v -u{email_address}:{password}-X POST -H"Content-Type: application/json"
旋度https://{subdomain}.zendesk.com/api/v2/community/posts/{post_id}/comments/{post_comment_id}/down.json\
-d'{"vote": {"user_id": 10056}}'\
-v -u{email_address}:{password}-X POST -H"Content-Type: application/json"
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://support.zendesk.com/api/v2/help_center{/locale}/articles/360026053753/up"
method:="POST"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add("Content-Type","application/json")
req.Header.Add("Authorization","Basic
" )// Base64 encoded "username:password"client:=&http.Client{}
res,err:=client.Do(req)
iferr!=nil{
fmt.Println(err)
return
}
deferres.Body.Close()
body,err:=io.ReadAll(res.Body)
iferr!=nil{
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
importcom.squareup.okhttp.*;
OkHttpClientclient=newOkHttpClient();
HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://support.zendesk.com/api/v2/help_center{/locale}/articles/360026053753/up")
.newBuilder();
RequestBodybody=RequestBody.create(MediaType.parse("application/json"),
"""
""");
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("POST",body)
.addHeader("Content-Type","application/json")
.addHeader("Authorization",Credentials.basic("your-email","your-password"))
.build();
Responseresponse=client.newCall(request).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'POST',
url:'https://support.zendesk.com/api/v2/help_center{/locale}/articles/360026053753/up',
headers:{
'Content-Type':'application/json',
'Authorization':'Basic
' ,// Base64 encoded "username:password"},
};
axios(config)
.then(function(response){
console.log(JSON.stringify(response.data));
})
.catch(function(error){
console.log(error);
});
Python
importrequests
url="https://support.zendesk.com/api/v2/help_center{/locale}/articles/360026053753/up"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"POST",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://support.zendesk.com/api/v2/help_center{/locale}/articles/360026053753/up")
request=Net::HTTP::Post.new(uri,"Content-Type":"application/json")
request.basic_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"vote":{
"id":37486578,
"value":1
}
}
删除Vote
DELETE /api/v2/help_center/votes/{vote_id}
Allowed for
- Agents
- 最终用户
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
vote_id | integer | Path | true | The unique ID of the vote |
Code Samples
Curl
旋度--request DELETE https://support.zendesk.com/api/v2/help_center/votes/35467\
--header"Content-Type: application/json"\
-u username:password
旋度https://{subdomain}.zendesk.com/api/v2/help_center/votes/{vote_id}.json\
-v -u{email_address}:{password}-X DELETE
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://support.zendesk.com/api/v2/help_center/votes/35467"
method:="DELETE"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add("Content-Type","application/json")
req.Header.Add("Authorization","Basic
" )// Base64 encoded "username:password"client:=&http.Client{}
res,err:=client.Do(req)
iferr!=nil{
fmt.Println(err)
return
}
deferres.Body.Close()
body,err:=io.ReadAll(res.Body)
iferr!=nil{
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
importcom.squareup.okhttp.*;
OkHttpClientclient=newOkHttpClient();
HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://support.zendesk.com/api/v2/help_center/votes/35467")
.newBuilder();
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("DELETE",null)
.addHeader("Content-Type","application/json")
.addHeader("Authorization",Credentials.basic("your-email","your-password"))
.build();
Responseresponse=client.newCall(request).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'DELETE',
url:'https://support.zendesk.com/api/v2/help_center/votes/35467',
headers:{
'Content-Type':'application/json',
'Authorization':'Basic
' ,// Base64 encoded "username:password"},
};
axios(config)
.then(function(response){
console.log(JSON.stringify(response.data));
})
.catch(function(error){
console.log(error);
});
Python
importrequests
url="https://support.zendesk.com/api/v2/help_center/votes/35467"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"DELETE",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://support.zendesk.com/api/v2/help_center/votes/35467")
request=Net::HTTP::删除.new(uri,"Content-Type":"application/json")
request.basic_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.request(request)
end
Example response(s)
204 No Content
// Status 204 No Content
null