How to get a working document preview link from MS Graph - rest

I am trying to get a preview link for the useres recent documents over MS Graph. Unfortunately the link the endpoint returns does not work.
To get the informations about a file I first call GET https://graph.microsoft.com/beta/me/drive/recent. Then I copy the driveID and the id of a document from the parentReference property.
To get the preview link I use the Endpoint POST https://graph.microsoft.com/beta/drives/<DriveID>/items/<DocumentID>/preview
and this works fine. But when I click on the link I get the error "This item might not exist or is no longer avaiable". The document exists on the SharePoint, otherwise it would not appear under "recent documents". The url looks like this: https://www.onedrive.com/embed?webUrl=xyz.sharepoint.com/sites/nameOfTheSite/docLibName&id=sites/nameOfTheSite/DocLibName&embed=xxx&authToken=xxx
I expect the response of the /preview endpoint should return a working url. Do I have to make some configurations on O365?
Many Thanks

The embed link (preview) does not look valid in your example since id parameter refers to container (library): sites/nameOfTheSite/DocLibName. It is not supported, instead embed link should refer to a file
Most likely the issue is due to itemId:
https://graph.microsoft.com/beta/drives/<DriveID>/items/<DocumentID>/preview
^^^^^^^^^^^^
in your example it seems refers to a library instead of a file. Make sure the proper itemId is specified.
For example, https://graph.microsoft.com/v1.0/me/drive/recent endpoint returns the following payload:
{
"value" : {
//another properties are omitted for a clarity
//...
"remoteItem": {
"id": "01ECKZLCWSR7F76B64KZFL7I3QGZVPJELU"
//...
"parentReference": {
"driveId": "b!79yKq-2MdkSDnQ7_1Pf3FOkRyDCajpRIvqtA7UrsEO-vu3D_qkpaT50Y6CMcSmFv",
"driveType": "documentLibrary",
"id": "01ECKZLCV6Y2GOVW7725BZO354PWSELRRZ"
},
}
}
}
where
remoteItem.Id - corresponds to item id for a file
remoteItem.parentReference.driveId - corresponds to drive id
Dont get confused with remoteItem.parentReference.Id which corresponds
to item id of library

Related

IBM Maximo REST service POST not setting attributes on MBO

I have tried to create a record of my customized object through REST service in IBM Maximo.
The problem is that I created the record but I can't assign values to the attributes.
Next I will show what I did and what happened:
I have an Object Structure called oxidato that represents my customized object.
I did a POST using POSTMAN to this URL:
http://hostname:port/maximo/oslc/os/oxidato?lean=1
In the body section this is the JSON I was trying to send:
{
"attribute1":"205",
"attribute2":"206"
}
The record was created but none of the attributes was filled.
In my opinion, the REST service received the POST but can´t read the body.
What am I missing? I add an image of the POSTMAN as example:
EDIT1: I update the POST in order to use the newest API RES (Thanks Dex!)
EDIT2: I add an image of the header
I have found that Maximo will often ignore incoming attributes that aren't in the Maximo namespace (http://www.ibm.com/maximo). You could go through the trouble of setting up your VALOR1 and VALOR2 attributes to be in that namespace, but it's easier to just tell OSLC to ignore namespaces. You do that by setting the "lean" parameter to "1".
In your case, go to the "Params" tab and add an entry with a name of "lean". Give it a value of "1" and then send your POST again. You should see "?lean=1" appear at the end of the POST URL along the top there, but your body content should remain unchanged.
EDIT:
On the other hand, it looks like (based on your URL) that you aren't actually using the newer JSON/OSLC REST API; It looks like you are using the older REST services. This IBM page gives you a lot of information on the newer JSON REST API, including the correct URLs for it: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html.
You should change your URL to /maximo/oslc/os/oxidato to use the newer API that naturally supports JSON and the lean parameter described above. This does required Maximo 7.6 to use though.
EDIT 2:
The attributes are often oddly case sensitive, requiring lowercase. Your example in your question of "attribute1" and "attribute2" are properly lowercase, but your screenshot shows uppercase attribute names. Try changing them to "valor1" and "valor2". Also, these are persistent attributes, right?
The response code received back (e.g. 200 - OK) and the response body will detail the record that was created.
I think you are correct in that the body of the post request is being ignored. Provided there are no required fields on the custom MBO your POST is probably creating an empty record with the next value in the sequence for the key field but you should see that in the response.
The following POST should create a record with values provided for attribute1 and attribute2 and provide a response with the record's identifier so that you can look it up in Maximo and show the values that were stored for attribute1 and attribute2:
http://hostname:port/maximo/rest/os/oxidato/?_format=json&_compact=1&attribute1=205&attribute2=206
Response: 200 OK
Reponse Body:
{ "CreateOXIDATOResponse": {
"rsStart": 0,
"rsCount": 1,
"rsTotal": 1,
"OXIDATOSet": {
"OXIDATO": {
"rowstamp": "[0 0 0 0 0 -43 127 13]",
"ATTRIBUTE1": "205",
"ATTRIBUTE2": "206",
"OXIDATOID": 13
}
} } }
You may also want to turn on debug logging for the REST interface in System Configuration -> Platform Configuration -> Logging for additional detail on what's happening in the log file.

I want to display articles using gatsby-source-facebook

I want to display the data of an article using gatsby-source-facebook.
But I don't know how to write a query.
I can't find the best query at http://localhost:8000/___graphql
I make a simple website with gatsby.js.
I want to get facebook article data (posting date and text) and display it on the site.
I installed gatsby-source-facebook for that.
And changed gatsby-config.js.
→ https://www.gatsbyjs.org/packages/gatsby-source-facebook/
//`gatsby-config.js`
plugins: [
{
resolve: `gatsby-source-facebook`,
options: {
places: [`${facebookPageID}`], // Can be either a numeric ID or the URL ID
params: {
fields: 'hours, posts { message, created_time }', // See Facebooks API to see what you can query for
},
key: process.env.FACEBOOK_GRAPH_TOKEN, // You will need to create a Facebook application and go through review in order to get an API token.
},
},
],
I don't know how to write a query, so I can't get the data. (Can not be displayed.)
For example, http://localhost:8000/___graphql
query {
site {
siteMetadata {
title
         description
}
    }
}
If you enter and execute}, the title and description of the site set in gatsby-config.js enter code here will be displayed. This is normal. So how do you write a query to display facebook article data?
I searched a lot to solve this problem, but I didn't find a solution.
I only found a similar question (How to add facebook comment plugin in Gatsby?) but it could not be resolved. This question was the same as what I wrote here (https://www.gatsbyjs.org/packages/gatsby-source-facebook/).
tl;dr:
Try this:
query {
allFacebookArticles {
edges {
node {
title,
description
}
}
}
}
Explanation
That plugin stores its data into types matching the format Facebook${type} where $type is the type of thing you're pulling (in your case, articles, so it'd be FacebookArticle).
From GraphiQL, though, you should be able to see that on the sidebar on the left.
Here's an example from my current project (with some other options open):

Invoking JIRA Rest API to create an issue containing a locked custom fields like Epic Name

I'm trying to create an Epic Issue in JIRA using the REST API.
There is a field called "Epic Name", which is required and locked.
When I submit the following JSON
URL: https://jira:443/jira/rest/api/latest/issue
{"fields":{"project":{"key":"TEST"},"issuetype":{"name":"Epic"},"summary":"TestSummary","Epic Name":"TestName"}}
The Response is:
Http Error : 400{"errorMessages":[],"errors":{"Epic Name":"Field 'Epic Name' cannot be set. It is not on the appropriate screen, or unknown."}}
What is wrong, since in the screen Epic Name is there and required (obviously, since it is a required attribute). What could be the problem?
Thanks
The problem is not that the field is not on the screen but that for JIRA API, the field name Epic Name is invalid/unknown. The actual ID of that field is customfield_10016 which you have to put in the query. The value should be the Issue Key for that specific Epic instead of just a name.
{
"fields": {
//other data
"customfield_10016": "PROJECTKEY-69"
}
}
I tried with customfield_10016 but it didn't work for me.
I have researched more about the same and got to know the custom field may differ for JIRA instance.
We can get custom field for our JIRA insatnce and project using below API and use it - http://<JIRA_URL>/rest/api/2/issue/createmeta?projectKeys=<ProjectKey>&issuetypeNames=<IssueType>&expand=projects.issuetypes.fields

Add a subpanel record to a SugarCRM account through REST API

Question: How do I create a subpanel record through the SugarCRM rest api endpoint for accounts?
Steps taken so far:
I've added a new package called, "transactionHistory" with a module named, "InvoiceHistory" using the SugarCRM studio.
I added a One to Many relationship to the Accounts module using studio.
I'm using NetSuite to push new invoices to the new module's record via the subpanel "create" option. Here's the code I'm using:
function createSugarTransaction(transaction, token) {
var url = 'https://crm.techsoft3d.com/rest/v10/Accounts/' + transaction.customer;
var headers = {
"Content-Type": "application/json",
"OAuth-Token": token
};
var now = (new Date()).toISOString();
var body = {transactionHistory_InvoiceHistory:
{
create: [{
name: transaction.docId,
transaction_date_c: transaction.date,
invoice_status_c: transaction.status,
due_date_c: transaction.duedate,
total_amount_c: transaction.total,
amount_due_c: transaction.remaining,
start_date_c: transaction.startdate,
end_date_c: transaction.enddate
}]
}
};
var response = nlapiRequestURL(url, JSON.stringify(body), headers, 'PUT');
return response;
}
The transaction object has been validated and the json object within the create: [] array has matching sugar fields (key) with the corresponding transaction object values.
When making the API call to sugar I'm successfully authenticated and have access to the custom module and accounts - so no problem there. However, when the call is returned to response it's showing the following error:
{"error":"no_method","error_message":"Could not find a route with 1 elements"}
I'm unsure of what else is needed in order for the record to be created. According to sugar's help documentation and developer community this should work. I'm using the basic information provided by sugarcrm support portal:
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/API/Web_Services/Examples/v10/module_POST/
According to other blog posts within the developer community, it should be as simple as adding the subpanel name, followed by an array of fields under the "create" object... similar to this:
var requestBody = { package_module:create[{name:value}]};
My initial thinking of what's wrong is:
1. my package_module name isn't correct, but I'm unable to find it anywhere within the applicaiton or help documentation.
2. the request body isn't formatted properly, even though it's structure was copied from this article https://developer.sugarcrm.com/2014/02/28/sugarcrm-cookbook2/
Any help would be appreciated.
try the createRelatedRecord api endpoint
type {sugarurl}/rest/v10/help to see a list of endpoints to look through, most of which have documentation and examples
https://crm.techsoft3d.com/rest/v10/help
your API url should have the name of the link (relationship) you want, in addition to the values in the POST payload
https://crm.techsoft3d.com/rest/v10/Accounts/{transaction.customer}/link/accounts_transactionhistory (or whatever your link's name is)
per the documentation for this endpoint, you just specify the field values in the payload
{
"first_name":"Bill",
"last_name":"Edwards"
}

How to get a single gist from github with GET /gists/:id

Somehow I fail to get a single gist from github.
Lets say i would like to get the following gist: https://gist.github.com/jrm2k6/6637633
Just copy&paste in URL field of your browser.
With https://api.github.com/users/jrm2k6 I can get the users info as json.
With https://api.github.com/users/jrm2k6/gists I can list all the public gists from this user as json.
But how do I get a specific gist GET /gists/:id with the id = 6637633 like it is described here in the api documentation: http://developer.github.com/v3/gists/#get-a-single-gist
With https://api.github.com/users/jrm2k6/gists/6637633 I should receive the content of the gist as json but instead I receive an error
{
"message": "Not Found",
"documentation_url": "http://developer.github.com/v3"
}
What am I doing wrong?
SOLUTION: You do not need the /users/:user. Working: https://api.github.com/gists/6637633
The documentation for all gists mentions
GET /users/:user/gists
Notice that the documentation for a single gist mentions
GET /gists/:id
so you do not need a user. https://api.github.com/gists/6637633 will work.