Zendesk API - Creating a ticket gives wrong ticket status - rest

Zendesk API documentation states that when creating a ticket through the API, the status field can be set to "new" (https://developer.zendesk.com/rest_api/docs/core/tickets#create-ticket), yet if I call the API with the following command specifying a value for status, it creates a token yet still sets status to be the default value of open:
curl -u <username>/token:<api_token> https://<subdomain>.zendesk.com/api/v2/tickets.json -d '{"ticket": {"subject":"test subject", "comment": { "body": "test body" }, "status": "new" } }' -H "Content-Type: application/json" -v POST
The relevant part of the response body is:
"ticket": {
"url": "https://<subdomain>.zendesk.com/api/v2/tickets/60.json",
"id": 60,
"external_id": null,
"via": {
"channel": "api",
"source": {
"from": {},
"to": {},
"rel": null
}
},
"created_at": "2016-05-05T13:30:01Z",
"updated_at": "2016-05-05T13:30:01Z",
"type": null,
"subject": "test subject",
"raw_subject": "test subject",
"description": "test body",
"priority": null,
"status": "open",
"recipient": null,
"requester_id": 5917202647,
"submitter_id": 5917202647,
"assignee_id": 5917202647,
"organization_id": 3740197137,
"group_id": 28473587,
"collaborator_ids": [],
"forum_topic_id": null,
"problem_id": null,
"has_incidents": false,
"due_at": null,
"tags": [],
"custom_fields": [],
"satisfaction_rating": null,
"sharing_agreement_ids": [],
"fields": [],
"brand_id": 1090897,
"allow_channelback": false
}
Am I doing something wrong?

So it turns out that if you assign a ticket to a group with only one member/agent, the ticket automatically gets assigned to that lone agent. As such, any ticket that's already assigned to a specific agent, is automatically set to open instead of new.
Because I was using a test subdomain, I was the only agent and so it was auto-updating the status from "new" to "open".

Hmm, I made the same API call (with my creds/subdomain) and it worked, setting the "status" to any option I choose (new, pending, solved).
Have you confirmed that all your credentials and subdomain are correctly inputted? Also, check the API settings in your Zendesk account. Try creating a new token and Save the settings.
If the API token still doesn't work, maybe try authenticating with password or making the request by means other than curl.

Related

how to update a ticket in Zammad via API

My goal is to create a ticket in Zammad using the API and then to update it (for.
the reference for such basic tasks is here
I am using Postman to send requests.
I use the bearer token authentication, the token has been generated for a user who is ticket.agent (and he is admin too).
I manage to succesfully create a ticket by doing a post request to
https://myzammadinstance.com/api/v1/tickets
and with this body:
{
"title": "Ticket generated from API - my test",
"group": "Users",
"article": {
"subject": "My Subject",
"body": "My body",
"type": "note",
"internal": false
},
"customer": "my#email.address",
"user": "my#email.address",
"note": "my notes"
}
This succesfully creates a ticket (with a given ID, let's say 1990).
Now i would like to update this ticket, so "replying from API".
I do a post request to
https://myzammadinstance.com/api/v1/tickets
and with this body:
{
"id": 1990,
"title": "updated title",
"group": "Users",
"state": "open",
"customer_id": 12,
"priority": "3 high",
"article": {
"subject": "some subject of update",
"body": "some message of update"
}
}
This executes but does not append a reply to my ticket 1990 but it generates a new ticket (with id 1991 and title "updated title").
I do not want to create a new ticket but just reply to an existing ticket.
May i misunderstood something but i double checked many times the documentation and the request body.
Anyone could give an hand please?
UPDATE: as stated in the comments is seems i should use
https://myzammadinstance.com/api/v1/tickets/1990
but this does not work: a new ticket is not created but the response has an error:
{
"error": "No route matches [POST] /api/v1/tickets/1990"
}
SOLUTION
The problem was in PUT vs POST, by using PUT and this endpoint
https://myzammadinstance.com/api/v1/tickets/1990
i managed to reply to the ticket.
To update the ticket you would need to use this endpoint:
PUT /api/v1/tickets/{id}
https://docs.zammad.org/en/latest/api/ticket.html#update

MS Graph API - Create Online Meeting, not generating with dial-in/conference information

I am calling to the MS Graph API to generate a Teams meeting, I previously was doing this same thing but with Application permissions, which MS has decided to deprecate. So I am now setting things up to do this call using User permissions, the new correct way to do it.
I finally got the call itself working in my environment, however I am only getting a URL to join the meeting, no Dial-in or Conference ID so that users can call in from a phone. I've ensured that the account I'm using to generate the meetings is set up with a license for Teams and a Microsoft Audio Conferencing license, but still cannot get Audio Conferencing to return anything other than NULL in the return.
Here's the call I am making to the /beta/me/onlineMeetings endpoint
POST /beta/me/onlineMeetings HTTP/1.1
Host: graph.microsoft.com
Content-Type: application/json
Authorization: Bearer (Token Removed)
{
"startDateTime":"2020-04-14T13:38:34.2444915-07:00",
"endDateTime":"2020-04-14T15:00:34.2464912-07:00",
"subject":"User Token Meeting"
}
And here is the main body of the result I get back from Graph:
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#users('REDACTED')/onlineMeetings/$entity",
"id": "REDACTED":meeting_NTMyZDEwMzYtY2NmZC00MzVlLTgxNDQtZjYxNDJhYjUxNTY4#thread.v2",
"creationDateTime": "2020-04-14T19:38:11.4760719Z",
"startDateTime": "2020-04-14T20:38:34.2444915Z",
"endDateTime": "2020-04-14T22:00:34.2464912Z",
"joinUrl": "REDACTED URL",
"joinWebUrl": "REDACTED URL",
"subject": "User Token Meeting",
"isBroadcast": false,
"autoAdmittedUsers": "Everyone",
"outerMeetingAutoAdmittedUsers": null,
"capabilities": [],
"videoTeleconferenceId": "REDACTED",
"externalId": null,
"audioConferencing": null,
"meetingInfo": null,
"participants": {
"organizer": {
"upn": "REDACTED UPN",
"identity": {
"phone": null,
"guest": null,
"encrypted": null,
"onPremises": null,
"applicationInstance": null,
"application": null,
"device": null,
"user": {
"id": "REDACTED USER ID",
"displayName": null,
"tenantId": "REDACTED TENANT ID",
"identityProvider": "AAD"
Just curious if anyone else is using this call and running into the same issues, or if you know if I need to specify anything in the actual call to Graph to tell it to generate Audio Conferencing as well?
This appears to be working now. My best guess is that I hadn't given the Audio Conferencing license enough time to replicate in our environment.

Get the currently allowed scopes of an OAuth user

I would like to know how to get a currently allowed scopes for a user signed in with GitHub.
Currently, I am maintaining a local copy of the authorized scopes, but I think it might be better to get the real data to avoid possible inconsistencies.
Any suggestions?
You can list all your personal access token or if you know the current ID of the access token you're looking for you can retrieve it individually.
This is the sample response for a single token. You are interested in the scopes element:
{
"id": 1,
"url": "https://api.github.com/authorizations/1",
"scopes": [
"public_repo"
],
"token": "",
"token_last_eight": "12345678",
"hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
"app": {
"url": "http://my-github-app.com",
"name": "my github app",
"client_id": "abcde12345fghij67890"
},
"note": "optional note",
"note_url": "http://optional/note/url",
"updated_at": "2011-09-06T20:39:23Z",
"created_at": "2011-09-06T17:26:27Z",
"fingerprint": "jklmnop12345678"
}

Get list of related tracks HTTP API SoundCloud

I wasn't able to find anything fitting in HTTP API documentation.
As I know, there's some tracks popping out in SC widget after current track is finished, therefore there is some related tracks functionality in SC itself, yet can we access it via API?
I.e get a list of tracks, related to given track's id.
Disclaimer: This is an undocumented endpoint and is subject to change at anytime by SoundCloud.
There is an undocumented endpoint that allows you to access a track's related sounds:
HTTP GET: https://api.soundcloud.com/tracks/[TRACK_ID]/related?client_id=[YOUR_CLIENT_ID]
You didn't specify a language, so i'm just going to give a high-level overview on how to use the endpoint.
First, get your track URL. I'll use this one as an example: https://soundcloud.com/msmrsounds/ms-mr-hurricane-chvrches-remix
Then hit the resolve endpoint to get the track_id.
HTTP GET: https://api.soundcloud.com/resolve.json?url=https%3A%2F%2Fsoundcloud.com%2Fmsmrsounds%2Fms-mr-hurricane-chvrches-remix&client_id=[YOUR_CLIENT_ID]
Response:
{
"status": "302 - Found",
"location": "https://api.soundcloud.com/tracks/90787841.json?client_id=[YOUR_CLIENT_ID]"
}
Next, hit the related endpoint with your track_id.
HTTP GET: https://api.soundcloud.com/tracks/90787841/related?client_id=[YOUR_ClIENT_ID]
The full response will give you up to 50 related tracks. The response is too large to post, but it's just an array of tracks.
[
{
"kind": "track",
"id": 112741336,
"created_at": "2013/09/27 09:40:29 +0000",
"user_id": 59817646,
"duration": 215896,
"commentable": true,
"state": "finished",
"original_content_size": 38068298,
"last_modified": "2015/04/04 20:17:24 +0000",
"sharing": "public",
"tag_list": "CHVRCHES Whitney Houston Zane Lowe",
"permalink": "chvrches-its-not-right-but-its",
"streamable": true,
"embeddable_by": "all",
"downloadable": false,
"purchase_url": null,
"label_id": null,
"purchase_title": null,
"genre": "Electronic",
"title": "CHVRCHES - It's Not Right But It's Okay (Whitney Houston Cover)",
"description": "CHVRCHES - It's Not Right But It's OK (Whitney Houston Cover) from Zane's Live Sessions",
"label_name": "",
"release": "",
"track_type": "recording",
"key_signature": "",
"isrc": "",
"video_url": null,
"bpm": null,
"release_year": null,
"release_month": null,
"release_day": null,
"original_format": "wav",
"license": "all-rights-reserved",
"uri": "https://api.soundcloud.com/tracks/112741336",
"user": {
"id": 59817646,
"kind": "user",
"permalink": "uknewmusic",
"username": "UKNewMusic",
"last_modified": "2013/09/27 09:38:04 +0000",
"uri": "https://api.soundcloud.com/users/59817646",
"permalink_url": "http://soundcloud.com/uknewmusic",
"avatar_url": "https://a1.sndcdn.com/images/default_avatar_large.png"
},
"permalink_url": "http://soundcloud.com/uknewmusic/chvrches-its-not-right-but-its",
"artwork_url": "https://i1.sndcdn.com/artworks-000058757165-6tnuep-large.jpg",
"waveform_url": "https://w1.sndcdn.com/XkEffI5hwjZ7_m.png",
"stream_url": "https://api.soundcloud.com/tracks/112741336/stream",
"playback_count": 680326,
"download_count": 0,
"favoritings_count": 9241,
"comment_count": 199,
"attachments_uri": "https://api.soundcloud.com/tracks/112741336/attachments",
"policy": "ALLOW"
},
{ ...
}
]

How to add ssh-keys via GitHub's v3 API?

I'm trying to add an ssh key via GitHub's v3 API, but it doesn't seem to be working.
What I'm doing is based on the instructions given here.
More specifically, I'm using the following:
KEY=$( cat ~/.ssh/id_rsa.pub )
TITLE=${KEY/* }
# the '/* ' above deletes every character in $KEY up to and including the last
# space.
JSON=$( printf '{"title": "%s", "key": "%s"}' "$TITLE" "$KEY" )
TOKEN=$( cat /path/to/tokenfile )
curl -s -d "$JSON" "https://api.github.com/user/keys?access_token=$TOKEN"
When I run the above, the response I get is:
{
"message": "Not Found"
}
...and, sure enough, when I check in my GitHub account, $KEY is not among the ssh-keys listed1.
What am I doing wrong?
Additional details
I get the same "message": "Not Found" response if I just run
curl -s "https://api.github.com/user/keys?access_token=$TOKEN"
If I replace the -s above with -i I see that, indeed, the returned status is 404 Not Found. And yet, the returned status for
curl -i "https://api.github.com/user/keys"
is 401 Unauthorized.
1 I know that the access token in $TOKEN is fine, and therefore it is not the reason for the "message": "Not Found" response, because
curl -s "https://api.github.com/user/repos?access_token=$TOKEN"
returns the correct information, and
curl -s "https://api.github.com/user/repos"
returns
{
"message": "Requires authentication"
}
Does your access token have "user" scope? A relevant excerpt from the docs:
Management of public keys via the API requires that you are authenticated through basic auth, or OAuth with the ‘user’ scope.
If your token does not have "user" scope, you will get a 404 response with a message of "Not Found".
To see the scopes associated with your tokens, use the "Authorizations" API:
curl -u <username> https://api.github.com/authorizations
In the example response below, the first authorization has "user" scope, but the second one does not.
enter code here
[
{
"id": 123,
"url": "https://api.github.com/authorizations/123",
"app": {
"name": "Foo",
"url": "https://foo.example.com/",
"client_id": "REDACTED-ID-1"
},
"token": "REDACTED-TOKEN-1",
"note": null,
"note_url": null,
"created_at": "2013-02-18T18:24:00Z",
"updated_at": "2013-05-06T14:17:00Z",
"scopes": [
"repo",
"user"
]
},
{
"id": 456,
"url": "https://api.github.com/authorizations/456",
"app": {
"name": "Bar",
"url": "https://bar.example.com/",
"client_id": "REDACTED-ID-2"
},
"token": "REDACTED-TOKEN-2",
"note": "for stuff",
"note_url": null,
"created_at": "2013-04-16T12:20:00Z",
"updated_at": "2013-05-13T21:28:00Z",
"scopes": [
"public_repo"
]
}
]
If you determine that this is the source of your problem, then you can resolve it in one of two ways:
Create a new token that has "user" scope, or
Update your existing token to add the "user" scope to it: "add_scopes": [ "user" ]
As of February 2014 the "user" scope no longer provides enough access to manage a user's SSH keys. The scope must be defined as:
read:public_key - provides read access to the user’s SSH keys
write:public_key - allows an app to read existing keys and create new ones
admin:public_key - enables an app to read, write, and delete keys