cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Query XML count zero

Hi,

I've a Web Request which gets data from SharePoint using GET method and I've stored the XML response in a variable called "ResponseContent".

To Extract data, I've used Query XML action and passing XML source's content as {Variable:ResponseContent} 

My XML looks like this:

<?xml version="1.0" encoding="utf-8"?>
<feed xml:base="https://mysite/sites/w/ProjRequest/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
  <id>f75e5831-abb3-44a7-aff8-8348d2fc33ab</id>
  <title />
  <updated>2017-09-05T14:09:33Z</updated>
  <entry m:etag="&quot;8&quot;">
    <id>Web/Lists(guid'77e2432b-22e9-479d-885a-d7134f3034f9')/Items(32)</id>
    <category term="SP.Data.Project_x0020_Request_x0020_listItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" href="Web/Lists(guid'77e2432b-22e9-479d-885a-d7134f3034f9')/Items(32)" />
    <title />
    <updated>2017-09-05T14:09:33Z</updated>
    <author>
      <name />
    </author>
    <content type="application/xml">
      <mSmiley Tongueroperties>
        <d:Title>2016-06-10T14_27_36.xml</d:Title>
        <dSmiley Tongueroject_x0020_Name>ProjectName1</dSmiley Tongueroject_x0020_Name>
        <dSmiley Very Happyepartment_x0020_01>Business Development</dSmiley Very Happyepartment_x0020_01>
      </mSmiley Tongueroperties>
    </content>
  </entry>
  <entry m:etag="&quot;8&quot;">
    <id>Web/Lists(guid'77e2432b-22e9-479d-885a-d7134f3034f9')/Items(34)</id>
    <category term="SP.Data.Project_x0020_Request_x0020_listItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" href="Web/Lists(guid'77e2432b-22e9-479d-885a-d7134f3034f9')/Items(34)" />
    <title />
    <updated>2017-09-05T14:09:33Z</updated>
    <author>
      <name />
    </author>
    <content type="application/xml">
      <mSmiley Tongueroperties>
        <d:Title>2016-06-14T15_24_09.xml</d:Title>
        <dSmiley Tongueroject_x0020_Name>ProjectName2</dSmiley Tongueroject_x0020_Name>
        <dSmiley Very Happyepartment_x0020_01>USA</dSmiley Very Happyepartment_x0020_01>
      </mSmiley Tongueroperties>
    </content>
  </entry>
  <entry m:etag="&quot;8&quot;">
    <id>Web/Lists(guid'77e2432b-22e9-479d-885a-d7134f3034f9')/Items(35)</id>
    <category term="SP.Data.Project_x0020_Request_x0020_listItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" href="Web/Lists(guid'77e2432b-22e9-479d-885a-d7134f3034f9')/Items(35)" />
    <title />
    <updated>2017-09-05T14:09:33Z</updated>
    <author>
      <name />
    </author>
    <content type="application/xml">
      <mSmiley Tongueroperties>
        <d:Title>2016-06-14T15_25_38.xml</d:Title>
        <dSmiley Tongueroject_x0020_Name>ProjectName3</dSmiley Tongueroject_x0020_Name>
        <dSmiley Very Happyepartment_x0020_01>Production Management</dSmiley Very Happyepartment_x0020_01>
      </mSmiley Tongueroperties>
    </content>
  </entry>
</feed>

My XPath query is /feed/entry/content/mSmiley Tongueroperties/d:Title

Return result as Text

Query result in VarCollection

To Count the collection, I've used "Count Items in Collection" Action

Target Collection as VarCollection

Total items as VarCount

I've published this workflow. When I ran this workflow, I'm getting VarCount as 0

My Intention is to get each mSmiley Tongueroperties stored in a collection and add it to current list as new list item. But I'm stuck on the above issue.

Could you please help me out here ?

Thanks,

Pandiarajan

Labels: (1)
0 Kudos
Reply
7 Replies
Workflow Hero

Re: Query XML count zero

Store the response in a Dictionary and then use the action "Get Item from Dictionary" and then set "Item name or path" to d/results and store the results in another dictionary variable.

Then use "Count Items in a Dictionary" and count your new dictionary output the total in a variable.

You can then use a loop to iterate through as many times as your "count" variable says you need to and use the "Get item from dictionary" action inside your loop to get the output of the index and then increment. 

d/results({Variable:LoopCounter})/Title

d/results({Variable:LoopCounter})/Project_x0020_Name

d/results({Variable:LoopCounter})/Department_x0020_01

use this action for each of the properties, store them in a variable and then create your new item before incrementing the index looping again until your index is equal to your count.

Does this make sense?

‌ 

Accept as Solution Reply
Workflow Hero

Re: Query XML count zero

Hi Ryan

Thanks for your reply.

I have added header Accept = application/json to get JSON Results from Web request.

I cannot store the response from Web Request action to Dictionary.

I'm trying to get list values from SharePoint on-premise. I must have to use Web request here because Call HTTP Request is not supporting credentials. There is no provision to save response content(for this action) to Dictionary. Where as Call HTTP Service action has option to save response content to dictionary. Also, Web Request has option to save response to Text Variable, I tried saving this Text variable to Dictionary using Set Workflow Variable action but it is still not working.

Am I doing anything wrong here?

.

Regards,

Pandiarajan

Accept as Solution Reply
Workflow Hero

Re: Query XML count zero

OK, so this is an O365 workflow calling an on-prem webservice?

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Query XML count zero

Yes. You're right

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Query XML count zero

Hi Ryan,

Any alternative ways to accomplish this task?

Thanks

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Query XML count zero

‌ Expert advise here?

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Query XML count zero

Hi!

Why don't you just use the simpler xpath: //mSmiley Tongueroperties

Or //mSmiley Tongueroperties/d:Title, and so on? That works

Regards,

Tomasz

Regards, Tomasz Poszytek
0 Kudos
Accept as Solution Reply