Script for Importing Feedback with UserVoice Admin API
Any interaction with the UserVoice Admin API requires a trusted API client. You can create one by following
this guide.
Creating the Script
Create a Ruby file with the following, substituting your own data at the top. This example is in Ruby, however you can use any language of your choice to achieve the same result.
require'net/http'require'net/https'require'json'# Change 'feedback' to the name of your UserVoice subdomain (leaving the quotes)subdomain="feedback"# Change "xxxe8ae9c6a3c039" to the bearer token you received in step 1 (leaving the quotes)token="xxxe8ae9c6a3c039"# Put your data into a json object with fields matching this example# The body and user email fields are requiredfeedback={"body":"UserVoice is great, it helps me understand our customers needs perfectly!",# Required"user":{"email":"carterjackson@gmail.com",# Required"name":"Carter Jackson"},}uri=URI.parse("https://#{subdomain}.uservoice.com/api/v2/admin/feedback_records")response=Net::HTTP.post(uri,feedback.to_json,"Content-Type"=>"application/json","Authorization"=>"Bearer #{token}")body=JSON.parse(response.body)ifresponse.code=="200"puts"Success"puts"Response Code: 200"puts"id: #{body['feedback_records'][0]['id']}"elseputs"Failure"puts"Response Code: #{response.code}"ifresponse.code=='422'puts"Missing #{body['errors'].keys.first}"elsifresponse.code=='401'puts"Invalid API token"endend
Running the Script
You can now run the script! It should import your feedback into UserVoice for later use. The output will show the status of the import.
For a successful import, you will see the following output containing the ID of your new feedback record:
123
SuccessResponseCode:200id:194823
For an unsuccessful import, you will see output showing what went wrong.
The following would indicate that the record did not include a body:
123
FailureResponseCode:422Missingbody
If your API token is missing or incorrect, the response will resemble the following:
123
FailureResponseCode:401InvalidAPItoken
Additional Information
For more complete documentation of the feedback_records endpoint, see the Admin API reference.
Didn’t find what you’re looking for?
Check out the UserVoice Help Center for more documentation.