0
votes

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?

3

3 Answers

0
votes

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.

enter image description here

0
votes

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!!

0
votes

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.