Is there any way to retrieve the name for a gist that github displays - github-api

When I browse to a gist on gist.github.com it displays a friendly name. E.g. for
https://gist.github.com/stuartleeks/1f4e07546db69b15ade2 it shows stuartleeks/baz
This seems to be determined by the first file that it shows in the list of files for the gist, but I was wondering whether there is any way to retrieve this via the API?

Not directly, but you can get with the Gist API the JSON information associated to a gist, reusing the id of your url:
GET /gists/:id
In your case: https://api.github.com/gists/1f4e07546db69b15ade2
It includes:
"files": {
"baz": {
"filename": "baz",
and:
"owner": {
"login": "stuartleeks",
That should be enough to infer the name stuartleeks/baz.

Related

Custom field for test plan in jira xray

I'm tring to import results to jira Xray using Rest API cucumber/mutipart with the following curl command :
curl -H "Authorization: Bearer $token" -F info=#Exec.json -F result=#file.json https://server/rest/raven/2.0/import/execution/cucumber/multipart
As this command creates a new test execution and we cannot report results to an existing one as bug mentionned https://jira.getxray.app/browse/XRAYCLOUD-2375
So I tried to add custom field related to test plan that already created
the problem that I cannot find the exact custom field's number I get always this error
{"error":"Error assembling issue data: Field \u0027customfield_11218\u0027 cannot be set. It is not on the appropriate screen, or unknown."
Here my Exec.json:
{
"fields": {
"project": {
"key": "project"
},
"summary": "Test Execution for cucumber Execution",
"issuetype": {
"name": "Test Execution"
},
"customfield_11218" : "ODI-1103"
}
}
I get the custom field for xml file exported from a test related to test plan:
<customfield id="customfield_11218" key="com.xpandit.plugins.xray:test-plans-associated-with-test-custom-field">
<customfieldname>Test Plans associated with a Test</customfieldname>
<customfieldvalues>
<customfieldvalue>[ODI-1103]</customfieldvalue>
</customfieldvalues>
</customfield>
In the case of Cucumber JSON reports, it's currently kind of an exception. If we want to link the results to a Test Plan, then we need to use the multipart endpoint that you mentioned.. which in turn always creates a new Test Execution.
The syntax for the JSON content used to customize the Test Execution fields should be something like:
{
"fields": {
"project": {
"key": "CALC"
},
"summary": "Test Execution for Cucumber execution",
"description": "This contains test automation results",
"fixVersions": [ {"name": "v1.0"}],
"customfield_11805": ["chrome"],
"customfield_11807": ["CALC-8895"]
}
}
(you can see a code example here; that repository contains examples in other languages)
In the previous example, the Test Plan custom field is "customfield_11807". Note that the value is not a string but an array of string of the issue keys of the connected Test Plans (usually just one).
From what you shares, it seems that you are referring to another custom field which has a similar name.
You should look for a custom field named "Test Plan" that has this description "Associate Test Plans with this Test Execution" (unless someone changed it).
To find the custom field id, you can ask your Jira admin to go to Custom Fields and then edit the field named "Test Plan"... Or you can also use Jira's REST API for that :)
https://yourjiraserver/rest/api/2/customFields?search=test%20plan
This will return a JSON content where you can see some custom fields, and you'll be able to depict the one you're looking for.

OnlyOffice conversion api keeps returning -1

I am trying to call my OpenOffice conversion API with following data:
{
"async": false,
"filetype": "docx",
"key": "Khirz6zgfTPdfd7",
"outputtype": "pdf",
"title": "Example Document Title.docx",
"url": "https://calibre-ebook.com/downloads/demos/demo.docx"
}
I am not certain about key property value, I used Khirz6zgfTPdfd7 which is also used in their example on https://api.onlyoffice.com/editors/conversionapi ; the document is also not the one stored on docserver.
The response I retrieve is:
<?xml version="1.0" encoding="utf-8"?><FileResult><Error>-1</Error></FileResult>
when means Unknown error.
I suppose the problem might be either in key or document URL. Can I use document that is not stored on docserver and how to generate the key properly?
Or do you think I miss something else?
I am trying to call my OpenOffice conversion API with following data
Seems to be ok, please send log files from /onlyoffice/documentserver/converter/ and /onlyoffice/documentserver/docservice/

Github API: determine if user or org

Given the URL https://github.com/foo/bar, I want to be able to get all the repos for foo. If foo is a user, I need to call api.repos.getForUser({username: 'foo'}) and if an org, I'll need to call api.repos.getForOrg({org: 'foo'}).
My problem is: how can I tell if "foo" is an org or a user?
Right now, I "solve" it in the costly way of trying to get an org called "foo", if I got it, I try to get its repos; if I end up getting an exception (I use promises) and if the code of the exception is "404", I assume "foo" is a user, and try to get user repos.
This is obviously inefficient, and has the side effect of adding calls that may trigger rate limit.
Is there an easier way to know whether "foo" is a user or an org?
As we all know, handling exceptions is costly. So instead of trying to get an org and handling the 404, you could instead look at the type property of the response to https://api.github.com/users/<username> in order to determine if the "user" is a user or organization and then proceed accordingly.
For example a call to my GitHub user API https://api.github.com/users/raghav710 returns
{
"login": "raghav710",
...
"type": "User",
...
}
And a call to an organization like https://api.github.com/users/Microsoft returns
{
"login": "Microsoft",
...
"type": "Organization",
...
}
Update: Doing it in a single call
I understand that you are already trying to access a URL https://github.com/<user or organization>/<repo name> and therein trying to get all the repos of that user or organization.
A suggestion is, instead of trying to do a GET on the above link, you could do a GET on https://api.github.com/repos/<user or organization>/<repo name>
For example doing a GET on https://api.github.com/repos/Microsoft/vscode
Gives
{
"id": 41881900,
"name": "vscode",
"full_name": "Microsoft/vscode",
"owner": {
"login": "Microsoft",
"id": 6154722,
...
"type": "Organization",
},
"private": false,
"html_url": "https://github.com/Microsoft/vscode",
...
}
As you can see the familiar type field is available under the owner key. You can use this to decide your next call
So even if there's an API call to differentiate, you'll still need that call to determine whether it's a user or not.
Considering the fact that most repositories should belong to users, why don't you reverse the checks? Try to retrieve the user repository, if that fails get the organization repository.
In addition, I'd cache as much information as necessary. Don't retrieve everything in real time while users use your tool. Many things won't change that often, if they're even able to be changed.

Azure Logic Apps - Moving Email Message with Move Message action

I'm fairly new to Logic Apps and I have an app that I'm trying to get to move an email to a subfolder of the Inbox in a shared mailbox, but I'm trying to generate the path based on the date and I cannot for the life of me get it to work. I don't know if my path syntax is wrong or what.
The subfolder structure is basically
- Inbox
- 2018
- Jan
- Feb
- Mar
- Etc
And I'm trying to generate the path based off the year and the month using the Expressions part of a field. I've got an expression that generates the path for me
concat('Inbox\',formatDateTime(convertFromUtc(utcNow(),'Mountain Standard Time'),'MMM'),'\',formatDateTime(convertFromUtc(utcNow(),'Mountain Standard Time'),'yyyy'))
When the logic app runs this generates the correct path string of Inbox\2018\Jan but when the Move Email action runs it always escapes the backslash and then says it can't find the folder Inbox\\2018\\Jan.
So I either have this format wrong, I can't put the email in a subfolder or there's another way to do this.
I tried using the folder picker to pick one of the month subfolders and then peeked at the code and it uses some base64 encoded string for the path. I've pasted below what the peeked code shows
{
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/Mail/Move/#{encodeURIComponent(triggerBody()?['Id'])}",
"queries": {
"folderPath": "Id::AAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA="
},
"authentication": "#parameters('$authentication')"
},
"metadata": {
"Id::AAMkADRmOTgyMDI1LThkODYtNDMwYy1iYThiLTIzODQwN2Y1OGMzYQAuAAAAAAA6K3dJssnITb8NwkAsBOo7AQBaJ9ZTcg-MSoOEUUjjUdOAAAAD0nvYAAA=": "Jan"
}
}
Does anyone know how I would be able to move an email to a subfolder without using the folder picker?
Edit: Since posting I've also tried using the following strings that also do not work
Inbox/2018/Jan
Inbox:/2018/Jan
/Inbox/2018/Jan
You cant really have the path in terms of a hierarchy folder structure in this particular logic app.
If you look at the Documentation for Office 365 Mail rest operations #
https://msdn.microsoft.com/office/office365/api/mail-rest-operations#MoveCopyMessages
You will notice that to Move messages what you actually need is a folder ID. Also if you look at the logic app Designer, when you select a folder directly from there and then look at the code view you will see an ID. It looks something like
"method": "post",
"path": "/Mail/Move/#{encodeURIComponent(triggerBody()?['Id'])}",
"queries": {
"folderPath": "Id::AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysaQAAA="
}
},
"metadata": {
"Id::AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysaQAAA=": "Jan"
},
The FolderID is unique to every folder. One easy way to find the FolderIDs for a folder is to use
https://developer.microsoft.com/en-us/graph/graph-explorer#
and after signing in , posting
https://graph.microsoft.com/beta/me/mailFolders/Inbox/childFolders
as the query which will give you the ChildFolders for Inbox the values will look something like the following for every folder
"value": [
{
"id": "AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQBT8bGPBJK8Qqoy01hgwH4rAAEJysWPAAA=",
"displayName": "AZCommunity",
"parentFolderId": "AAMkADZmZDQ5OWNhLTU3NzQtNDRlZC1iMDRlLTg5NTA1NGM3NWJlZgAuAAAAAAAhZj7Qt8LySYhKvlgbXRNVAQDX8XL9o4tkR5vF5sEdh44eAIYnQnhhAAA=",
"childFolderCount": 0,
"unreadItemCount": 5,
"totalItemCount": 169,
"wellKnownName": null
},
For what you are trying to do, you will have to do additional work to map the folders to the folder ID and then assign using that. I would suggest using Azure Functions to easily do this.

XPages Extlib REST update (HTTP PUT) on calendar event is returning error code (cserror : 1028)

I am trying to update a calendar event in Domino Mail Calendar by using the REST data service "calendar" from the latest xpages extlib release "ExtensionLibraryOpenNTF-901v00_13.20150611-0803".
Has anybody done this with a successful return?
Unfortunately I haven't had any success trying to update a calendar event. I was successful getting the list of events, creating events, deleting an event, but to update an event seems to be somehow special. The PDF documentation for the calendar service is quite short on this point. My domino server is accepting all protocols including PUT. I am using the JSON format for my REST calls. The UPDATE I tried as described in the documentation with iCAL as well, but getting the same error.
I am using the Firefox REST Plugin for checking out the service, before I am implementing it.
Im using PUT, with content-type "text/calendar" as well "application/json".
My URL:
http://sitlap55.xyzgmbh.de:8080/mail/padmin.nsf/api/calendar/events/4D750E2B8159D254C1257E9C0066D48D
My Body looks like this, which is the easiest event type, a reminder (but I tried it with meeting and appointment as well):
{"events":[{"UID:"4D750E2B8159D254C1257E9C0066D48D","summary":"Ein Reminder update","start":{"date":"2015-08-13","time":"13:00:00","utc":true}}]}
This is how I return the event by a GET:
{
"href": "/mail/padmin.nsf/api/calendar/events/4D750E2B8159D254C1257E9C0066D48D-Lotus_Notes_Generated",
"id": "4D750E2B8159D254C1257E9C0066D48D-Lotus_Notes_Generated",
"summary": "Ein Reminder",
"start": {
"date": "2015-08-12",
"time": "07:00:00",
"utc": true
},
"class": "public",
"transparency": "transparent",
"sequence": 0,
"x-lotus-summarydataonly": {
"data": "TRUE"
},
"x-lotus-appttype": {
"data": "4"
}
}
This is the error I get:
{
"code": 400,
"text": "Bad Request",
"cserror": 1028,
"message": "Error updating event",
"type": "text",
"data": "com.ibm.domino.calendar.store.StoreException: Error updating event\r\n\tat com.ibm.domino.calendar.dbstore.NotesCalendarStore.updateEvent(NotesCalendarStore.java:229)\r\n\tat ... 65 more\r\n"
}
The attributes in the body I tried a lot of different things, using the id, no id, an UID like in the calendar service doumentation, ...
What am I doing wrong here?
The solution:
Using the PUT method, the URL which worked looks like this:
http://sitlap55.xyzgmbh.de:8080/mail/padmin.nsf/api/calendar/events/4D750E2B8159D254C1257E9C0066D48D-Lotus_Notes_Generated
the BODY looks like this:
{"events":[{"id":"4D750E2B8159D254C1257E9C0066D48D-Lotus_Notes_Generated","summary":"Some Reminder update #6","start":{"date":"2015-08-13","time":"10:00:00","utc":true}}]}
What I figured out was, that the "id" attribute is required ! a bit strange, because it is already in the URL.
I just checked against the documentation for Domino Access Services (DAS) 9.0.1 - and the example they have there actually works.
I tried a few things before that, e.g. if I could PATCH (change individual fields) or PUT (change ALL fields) just specifying the non-system fields. None of these worked. But taking the response from creating (or getting) the event and put it into a PUT request and adjust e.g. start time works fine.
Looking at your example I think the issue is similar as you do not include the end time in the request. But even so you seem to have to include the entire record as it is returned from the service - and please note that the url must end on the ENTIRE id (i.e. including "...-Lotus_Auto_Generated") :-)
/John
Edit:
It seems you don't need to add all fields... But be aware of the side effects of not specifying fields... You need to test it for yourself!

Resources