2

In SP Online I have the following problem:

The query: https://mysite/_api/search/query?querytext='contenttype:My content Type'

if I query by the content-type using the browser I get the

d/query/PrimaryQueryResult/RelevantResults/RowCount

equals 4, but if I query through a Call Web Service Action from Workflow on Sharepoint Design.

using the same URL, RequestHeaders beeing a dictionary with both Accept and Content-Type being initialized with application/json;odata=verbose parameter, it is not returning the same data, is actually returning 0 and no elements.

I am just trying to count the number of elements from a certain content type using the workflow, any ideas ?

1

It is probably because of a permission problem.

Workflow runs under an App identity. That App identity has only access to the current sub-site.
Your search request probably returns 4 results when considering all your sites and if you have access to all results...
However, when called from a WF, it gets only result the WF has access to, so only results from the current sub-site, so maybe 0 result...

One option would be to configure the workflow to use App-only permissions (+ site collection Full Control) and set your "Call a Web service" action from an "App stage". You'll then get results from the entire site collection (but still not from all site collections :()

Here's a link that explains you how to allow your WF to use App-only permissions and add an App stage in it.
Note that to allow entire Site collection, you need to change http://sharepoint/content/sitecollection/web at step #7 to http://sharepoint/content/sitecollection/sitecollection (as seen in section "Eventual Resolution" of http://www.fabiangwilliams.com/2014/06/19/gotcha-on-sharepoint-designer-workflows-in-app-step/).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.