How to get Sharepoint user by Title using REST? - rest

I'm trying to search for a given user on a Sharepoint site using "lastname, firstname". I was able to use the following url to get the total list of site users as a large XML document:
https://thissite.com/sites/thatsite/_api/web/siteusers/
However, I haven’t been able to figure out how to search by Title. When I use the following url:
https://thissite.com/sites/thatsite/_api/web/siteusers/getbytitle(“lastname,%20firstname”)
I get this error:
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>
-1, Microsoft.SharePoint.Client.InvalidClientQueryException
</m:code>
<m:message xml:lang="en-US">
The expression "web/siteusers/getbytitle("lastname, firstname")" is not valid.
</m:message>
</m:error>
When I use the following url to get the same user's data:
https://thissite.com/sites/thatsite/_api/web/siteusers/getbyid(41)
Then I successfully get XML returned with that user's data.
I guess I could just parse the list obtained from /siteusers and load it into a searchable data object, but I was hoping for something more direct.

UserCollection resource does not expose getbytitle method, that's the reason why you get this exception.
In order filter user by title you could utilize $filter query option as demonstrated below:
https://contoso.sharepoint.com/_api/web/siteusers?$filter=Title eq '<Title>'

Related

How to get purchase order documents from tradeShift API?

I am trying to get the trade shift purchase order using their API.
FYI, While I am making an API request,
I am using OAuth1.
I am using endpoint
https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents?limit=5
In the header, When I set Accept as application/JSON, I am getting a response like
{
"itemsPerPage": 5,
"itemCount": 2,
"indexing": false,
"numPages": 1,
"pageId": 0,
"Document": []
}
But If I add nothing in the Header, I am getting an XML response.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ts:DocumentList xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ts="http://tradeshift.com/api/public/1.0" xmlns:ns6="http://tradeshift.com/api/1.0" xmlns:ns7="http://tradeshift.com/api/2.0" xmlns:ns8="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:ns9="urn:oasis:names:specification:ubl:schema:xsd:Quotation-2" xmlns:ns10="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2" xmlns:ns11="urn:oasis:names:specification:ubl:schema:xsd:Order-2" xmlns:ns12="urn:oasis:names:specification:ubl:schema:xsd:OrderChange-2" xmlns:ns13="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2" xmlns:ns14="urn:oasis:names:specification:ubl:schema:xsd:Reminder-2" xmlns:ns15="urn:oasis:names:specification:ubl:schema:xsd:RemittanceAdvice-2" xmlns:ns16="urn:oasis:names:specification:ubl:schema:xsd:ReceiptAdvice-2" xmlns:ns17="urn:oasis:names:specification:ubl:schema:xsd:Catalogue-2" xmlns:ns18="https://tradeshift.com/documents/ubl/xsd/Requisition-2" xmlns:ns19="urn:oasis:names:specification:ubl:schema:xsd:OrderResponse-2" xmlns:ns20="urn:oasis:names:specification:ubl:schema:xsd:RequestForQuotation-2" xmlns:ns21="urn:oasis:names:specification:ubl:schema:xsd:OrderResponseSimple-2" xmlns:ns22="urn:oasis:names:specification:ubl:schema:xsd:OrderCancellation-2" xmlns:ns23="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2" indexing="false" numPages="1" pageId="0" itemsPerPage="5" itemCount="2"/>
I am not quite sure if the document is already there as UBL format.
Can you please ensure, if the document is already there as UBL.
If document is there, then How can I parse the document?
And if the document is not there, how can I get the documents?
The document is not there, that both responses are the same just the format is different.
In order to get the Documents that you receive in your Tradeshift account you should follow the below steps:
get the list with all the documents available in your account using the below API:
GET https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents?type=order Content-Type=application/json Accept=application/json Authorisation=oauth1
As response, you will have a JSON with all the orders in your account and the details you will need to retrieve the UBL file of the order.
From the JSON resulted in point 1 using the DocumentId of the order you want to get make the below call
GET https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents/{DocumentUUID} Content-Type=application/json Accept=application/xml Authorisation=oauth1
Once you get a file in order to get it marked as processed you can also tag the document using the below API call:
PUT https://api.tradeshift.com/tradeshift/rest/external/documents/{DocumentId}/tags/{your-tag}
At the first call, you can then add more parameters like withouttag in order to filter out the documents you have tagged already, like in the below call:
`GET https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents?type=order&withouttag={your-tag}`

how to get dictionary value from webrequest using sharepoint designer

I am trying to retrieve a value from a HTTP web service call in sharepoint designer. This should be simple. the Rest query is simple, and always returns only a single value:
https://Site.sharepoint.com/sites/aSiteName/_api/web/lists/getByTitle('MyListTitle')/items/?$select=Title&$top=1
In the Sharepoint Designer workflow, I'm setting the required Accept and Content-type header to the value of "application/json;odata=verbose
I am unable to get the value of the "Title" field that is returned by the call.
when I execute the REST query in the browser, I get the following data returned:
{"d":{"results":[{"__metadata":{"id":"af9697fe-9340-4bb5-9c75-e43e1fe20d30","uri":"https://site.sharepoint.com/sites/aSiteName/_api/Web/Lists(guid'6228d484-4250-455c-904d-6b7096fee573')/Items(5)","etag":"\"1\"","type":"SP.Data.MyListName"},"Title":"John Doe"}]}}
I've tried dozens of variations of the dictionary 'query', but they always return blank.
I'm using the 'get an item from a dictionary' action in SP Designer, using item name or path values like:
d/results(0)/Title
d/Title
d/results/Title
and literally dozens of other variations - but it always returns blank.
I'm writing the raw response from the webRequest to the list for debugging, and it shows the value like this:
{"odata.metadata":"https:\/\/site.sharepoint.com\/sites\/aSiteName\/_api\/$metadata#SP.ListData.MyListTitle&$select=Title","value":[{"odata.type":"SP.Data.MyListTitle","odata.id":"616ed0ed-ef1d-405b-8ea5-2682d9662b0a","odata.etag":"\"1\"","odata.editLink":"Web\/Lists(guid'6228d484-4250-455c-904d-6b7096fee573')\/Items(5)","Title":"John Doe"}]}
I must be doing something simple that is wrong?
Using "d/results(0)/Title" is right. Check the steps in article below to create a workflow.
CALLING THE SHAREPOINT 2013 REST API FROM A SHAREPOINT DESIGNER WORKFLOW
It working fine in my test workflow.
I faced the exact same issue. In my case the reason was that in the API call, the header was not set properly.
As you would have noticed many times, that if you type the variables inline when creating the "Call Http Web service" action, those might not get set properly. The surest way is to open the properties and set from there. In my case when i opened the properties i found that RequestHeaders was not set. Once i set it from there, i got the desired results.
Hope this helps to someone in future, this question being unanswered till now!!
tried dump those json called from sharepoint workflow into a list. Sometimes you'll get a different format than when you called that from browser. I experienced this issue when calling API projectserver (project online). When I called it using servistate (chrome extension) it returns d/results, but when I dump the value into the list I got value and yet I used same request header value.

Whats the sharepoint rest endpoint to get a web by its id

I have a webid and a listid in a sharepoint page. I'm trying to construct a rest url to get to the list.
I cant figure out the url to get the web given the WebID.
I tried
https://xxxx.sharepoint.com/_api/web/webs(guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d')
https://xxxx.sharepoint.com/_api/web/webs('33213c5c-30e5-468c-87f7-52b48a7b6a3d')
https://xxxx.sharepoint.com/_api/web/webs/GetById('33213c5c-30e5-468c-87f7-52b48a7b6a3d')
How do I get at the web with that id? I need to get a list in the web.
I was thinking it was going to be as simple as
https://xxxx.sharepoint.com/_api/web/webs(guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d')/lists(guid'the-list-id'), but I cant get at the web!
++++++++++++++++ mReply to vadim ++++++++++++++++++++++++
Thanks Vadim,
You got me pointed in the right direction
This url will get me to the web:
https://xxx.sharepoint.com/_api/web/webs?$filter=iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d'
This url will get me all items in all lists in all webs
https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items
This url will get me all items in all lists in a specified web:
https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items&$filter=iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d'
But how doe I get all items in a specified list in a specified web?
This doesnt work:
https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items&$filter=((iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d' ) and (Lists/Id eq guid'd38444af-dd7f-404b-9e75-b1f8c6cdee7d' ))
Its a valid Web id and a valid list id, but sharepoint complains :m:message xml:lang="en-US">Field or property "Id" does not exist.
any ideas?
Web resource could be retrieved using $filter query option as demonstrated below:
/_api/web/webs?$filter=ID eq guid'c01e1b4a-e671-431d-97aa-4b02a57803c7'
In order to retrieve the corresponding List resource by id you could consider the following approach:
Perform request to get Web Url by its Id:
/_api/web/webs?$select=ServerRelativeUrl&$filter=ID eq
guid'c01e1b4a-e671-431d-97aa-4b02a57803c7'
Get List by id: {web url}/_api/Web/Lists(guid'b778bbec-dd69-4a6c-9437-c73972c36292')
where {web url} is web site url found in the first request

v3 IPP FindAll is not returing the correct paged data when Customers are sub-customers

I'm using the below line:
commonService.FindAll(new Intuit.Ipp.Data.Customer(), currentPage, itemListPageSize).ToList();
When returning multiple pages the paging isn't returning the right rows on page if there are sub-customers. To reproduce, just create several customers and retrieve the second page like:
commonService.FindAll(new Intuit.Ipp.Data.Customer(), 2, itemListPageSize).ToList();
When it retrieves page 2, the first page's data is returned.
Am I doing something wrong?
FindAll with paging actually uses query endpoint.
Please mention if you are trying this call against QBD/QBO.
Can you please capture the raw request and response of the above call and share in this post.
(for that you can enable logger as mentioned in the following docs, or you can configure your app with any http snooper like Fiddler.)
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/logging
You can try this call directly using ApiExplorer. Please verify if you are getting the same result.
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/00300_query_operations/0100_key_topics#Pagination
Thanks

I am having problems running Facebook FQL queries that include long user ids

I am having problems running queries with FQL that include a supplied "Large"(beginning with 10000..) User ID
here is an example of one that is not working:
fql?q=SELECT uid, first_name,last_name,pic,pic_square,name
FROM user
WHERE uid=100002445083370
Is there a way to encapsulate the long number so it's passed as a string?
here is another example:
/fql?q=SELECT src_big
FROM photo
WHERE aid IN (SELECT aid
FROM album
WHERE owner=100002445083370 AND type="profile")
ORDER BY created DESC LIMIT 1
Has anyone been able to solve this issue? I am testing the queries in the graph explorer with no luck as well.
I see what the problem is,
The User id I am trying to pass is supposed to be: "100002445083367", but from querying the list of friends and grabbing their User Id, I am getting back "uid":1.0000244508337e+14 which is being shortened to: 100002445083370 (php removing the e+14) throwing off the second query. I need to make sure the id I am grabbing is staying as a string value not a number while I pass it back and forth from PHP and Javascript.
The problem is because of the way PHP handles JSON_DECODE. I had to modify Facebook PHP SDK and add a preg_replace previous to the json_decode. It will make sure json_decode doesn't convert large integers to floats by first converting them to strings.
here is the code:
line 803 from base_facebook.php:
$result = json_decode(preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $this->_oauthRequest($this->getUrl($domainKey, $path),$params)), true);
here is more information on the subject:
http://forum.developers.facebook.net/viewtopic.php?id=20846
What do you mean by "not working"?
That query works for me in Graph API explorer but the response is
{
"data": [
]
}
I think that user-id isn't valid; https://www.facebook.com/profile.php?id=100002445083370 gives a "Page not found" error for me.