Create new Response using Survey Monkey REST API V3 - surveymonkey

I am trying to create new responses using SurveyMonkey API, I am following this document provided by SurveyMonkey: https://developer.surveymonkey.com/api/v3/?shell#collectors-id-responses
and here is the request I am making:
curl -i -X POST -H "Content-Type: application/json" -H "Authorization:bearer ACCESS_TOKEN" https://api.surveymonkey.com/v3/surveys/{suvey_id}/responses -d '{"custom_variables":{"custvar_1": "one", "custvar_2": "two"},"response_status": "completed","custom_value": "custom identifier for the response","date_created": "2015-10-06T12:56:55+00:00","ip_address": "127.0.0.1", "pages": [{"id": "{page_id}","questions": [{"answers": [{"text": "Sample Text Response"}], "id": "{questions_id}"}, {"answers": [{"choice_id": "{choice_id}"}], "id": "{questions_id}"}]}]}'
and I am getting a 404 response:
{"error": {"docs": "https://developer.surveymonkey.com/api/v3/#error-codes", "message": "There was an error retrieving the requested resource.", "id": "1020", "name": "Resource Not Found", "http_status_code": 404}}
I have verified values of "choice_id", "questions_id", "page_id" and "survey_id", all of them are correct but I am still getting a 404, I am completely stuck down with this issue, any help in this regard will be highly appreciated.
Thanks!

Related

Why am I getting authorization code is not in a recognised format?

Hello everyone I need help please. This is about Seatgeek Oauth request.
In Postman, entered the required fields to get access token.However I am getting this error below.
{
"status": 400,
"message": "Oauth code invalid",
"errors": [
{
"message": "Oauth code invalid",
"short_message": "Code invalid",
"verbose_message": "The authorization code provided was not in a recognized format.",
"hint_message": "Switch code verifier",
"category": null,
"parameter": null,
"code": 40322
}
],
"meta": {
"status": 400
}
}
Now let me add the endpoints I used
Base endpoint: https://api.seatgeek.com/2/oauth/access_token
Params: client_id = xxxxxxxxx
Params: scope = offline_access,read-user-first-name,read-user-email,read-user-phone,view-soundersfc-crm-id
Params:grant_type = authorization_code
Body:x-www-form-urlencoded:
client_secret = xxxxxxxxxxx
code = “ ”
The full url will be something like this : https://api.seatgeek.com/2/oauth/access_token?client_id=xxxxxxxxx&scope=offline_access,read-user-first-name,read-user-email,read-user-phone,view-soundersfc-crm-id&grant_type=authorization_code
Please help me identify this code error. Any help will be highly appreciated
here is the Seatgeek Oauth documentation.
https://partners.seatgeek.com/enterprise-client-integration/oauth
SeatGeek API OAuth documentation not accuracy. you need a little change a scope.
(just use offline_access)
#1 Using this URL from Browser
https://seatgeek.com/oauth2?scope=offline_access&client_id=MzA...zcy
#2 You can get the code in URL address of browser
It will return your registered redirect URL and code
Copy that code and call POST to get token by curl
#3 Get token
curl -X "POST" "https://api.seatgeek.com/2/oauth/access_token" \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
--data-urlencode "code={received_code_from_#2}" \
--data-urlencode "client_id={your_client_id}" \
--data-urlencode "client_secret={your_client_secret}" \
--data-urlencode "grant_type=authorization_code"
Note #1
you can get the client id /secret from developer portal
Note #2
code is JWT format. The payload is this content.
I decoded from jwt.io

calling activities:list fails on using parameter `mine=true` (Youtube Data API V3)

I have been trying to use the API to retrieve my activities but I'm receiving the following JSON error.
{
"error": {
"code": 403,
"message": "The request is not properly authorized.",
"errors": [
{
"message": "The request is not properly authorized.",
"domain": "youtube.activity",
"reason": "forbidden"
}
]
}
}
, although I use https://www.googleapis.com/youtube/v3/activities?mine=true&key={my_api_key}&part=contentDetails and I use OAuth2 client to get an access token which I use on calling the API.
I tried to use the samples but I'm receiving the same error.
Is this a bug or I'm doing something wrong?
More details
I use the given link in postman with the GET method and I put a valid access token in the token field with TYPE=OAuth2 and Prefix=Bearer
According to the official specification of the Activities.list API endpoint, for to be able to use its mine request parameter, you have to issue the call to the endpoint while passing to it proper credentials:
mine (boolean)
This parameter can only be used in a properly authorized request. Set this parameter's value to true to retrieve a feed of the authenticated user's activities.
Therefore, using an API key is not sufficient (neither is required when issuing a properly authorized request).
Do note that the JSON error response obtained from the API agrees entirely with the specification quoted above.
According to the official (programming language agnostic) procedure, for to obtain a valid fresh access token from the API, issue a simple curl instance as follows:
$ curl \
--data 'grant_type=refresh_token' \
--data-urlencode "client_id=$CLIENT_ID" \
--data-urlencode "client_secret=$CLIENT_SECRET" \
--data-urlencode "refresh_token=$REFRESH_TOKEN" \
https://oauth2.googleapis.com/token
Above, $CLIENT_ID and $CLIENT_SECRET are the values of the corresponding properties of your client secrets JSON file you've got from Google's developers console. The $REFRESH_TOKEN is your (long-lived) refresh token you've obtained upon running a successful OAuth2 authentication/authorization flow.
The output obtained from curl when successful would look like:
{
"access_token": "...",
"expires_in": 3599,
"scope": "...",
"token_type": "Bearer"
}
A call to the Activities.list endpoint as yours above using curl is immediate:
$ curl \
--header "Authorization: Bearer $ACCESS_TOKEN" \
'https://www.googleapis.com/youtube/v3/activities?mine=true&part=contentDetails&maxResults=25'
The parameter $ACCESS_TOKEN above is your freshly obtained valid access token; the output of curl would look like:
{
"kind": "youtube#activityListResponse",
"etag": "...",
"items": [
{
"kind": "youtube#activity",
"etag": "...",
"id": "...",
"contentDetails": {
...
}
},
...
],
"pageInfo": {
"totalResults": ...,
"resultsPerPage": 25
}
}
For to run the above curl commands on a Windows machine under CMD.exe -- assuming that you've substitued the $-variables yourself manually --, do replace the backslash character at the end of each line above with the caret character, ^. The percent character % should be doubled, i.e. should be replaced with %%, and the single quote characters ' should be replaced with double-quote characters ".

Getting list of users in Google Admin SDK

I have OAuth login in my app. After that I have access_token.
I check token in google token info service:
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<access_token>
And It returns:
{
"issued_to": "554651647288-tquejcu6mctplq4kin5dd9r81mtkg3vv.apps.googleusercontent.com",
"audience": "554651647288-tquejcu6mctplq4kin5dd9r81mtkg3vv.apps.googleusercontent.com",
"scope": "https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.orgunit https://www.googleapis.com/auth/admin.directory.user",
"expires_in": 3299,
"access_type": "online"
}
As you can see I have admin user directory permission.
Then I send GET request for getting information about user
curl -X GET https://www.googleapis.com/admin/directory/v1/users/test_user#test.com?access_token=<access_token>
And google returned me right user information. After that I decided to get list of users.
curl -X GET https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&access_token=<access_token>
And google returned me:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
But I don't understand why google returned me so error.
Could you please help me with this problem?
Thanks.
There are two solutions here.
1.This is the simple one. Put the URL params in quotes. This should do the trick - (fake access token used)
curl "https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&access_token=asdf.AHEasdfyIc9vuPQ_BGONpzEJkasdfWYXGujPw5iPI"
You don't need to pass in -X GET as that is the default.
2.In general it is bad practice to send the access_token in the URL as this URL may get logged somewhere along the way for innocuous reasons. You can also do this through HTTP Header of Authorization -
curl -H "Authorization: Bearer asdf.AHEasdfyIc9vuPQ_BGONpzEJkasdfWYXGujPw5iPI" https://www.googleapis.com/admin/directory/v1/users?customer=my_customer

How to create remote JIRA Issue with ruby-jira Gem

I'm trying to use the jira-ruby Gem to interface with a remote JIRA server with 5.x REST API.
Accessing data on the server works well, but it seems I can not create a new JIRA issue remotely. The Gem's documentation is minimal, and there are no examples provided.
Can somebody provide a working example on:
how to create a remote JIRA Issue with ruby-jira
how to attach a file to an existing Issue
To create new JIRA Issue use:
CODE:
issue = client.Issue.build
issue.save({"fields"=>{"summary"=>"blarg from in example.rb","project"=>{"id"=>"10001"},"issuetype"=>{"id"=>"3"}}})
issue.fetch
pp issue
Or
You can try REST APIs to create JIRA Issue.
Using IDs
The first example creates an issue by specifying the project ID and issue type ID.
Request
curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
Data
Here's the JSON:
{
"fields": {
"project":
{
"id": "10110"
},
"summary": "No REST for the Wicked.",
"description": "Creating of an issue using ids for projects and issue types using the REST API",
"issuetype": {
"id": "1"
}
}
}
Response
The response provides the issue ID, issue key, and the URL to the issue (which can then be used to GET additional data, PUT updates, etc).
{
"id":"39001",
"key":"TEST-102",
"self":"http://localhost:8090/rest/api/2/issue/TEST-102"
}
Using Project Key and Field Names
Alternatively, you can create an issue by specifying the project key and field names.
Request
curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
Data
{
"fields": {
"project":
{
"key": "TEST"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Bug"
}
}
}
Response
{
"id":"39000",
"key":"TEST-101",
"self":"http://localhost:8090/rest/api/2/issue/TEST-101"
}
Source: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+APIs

YouTube V3 Create Broadcast

I am trying to create a broadcast using YouTube's v3 API. My request looks like this:
curl -H "Authorization: Bearer ******************" -H "Content-type: application/json" -d " {\"snippet\":{\"title\":\"Hello\", \"scheduledStartTime\":\"2014-01-30T00:00:00.000Z\", \"scheduledEndTime\":\"2014-01-31T00:00:00.000Z\"},\"status\":{\"privacyStatus\":\"public\"}}" https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet,status
But the response I get from google is this:
{
"error": {
"errors": [
{
"domain": "youtube.liveBroadcast",
"reason": "liveBroadcastForbidden",
"message": "Request is not authorized"
}
],
"code": 403,
"message": "Request is not authorized"
}
}
I can confirm that the access token I am passing is correct.
Is there something I am doing wrong here?
Livestreaming API is only available to partners right now. It will be more widely available later.
If you have gotten the granted access, you should enable YouTube APIs from API Console. It looks like you haven't enabled them.

Resources