Solved

How to create a site using web service calls?


Userlevel 2
Badge +5

Hi,

 

We have a workflow that will need to create a site (eventually using a custom template). However, the problem is we only have a standard license, so there is no 'create site' action. I have been trying to do this via a web service call (using this Nintex Workflow SharePoint Online Create Sub Site using Call HTTP Web Service Action | reshmeeauckloo  post), but I'm getting a bad request response, and of course the site isn't being created. I have noticed that posts for Nintex on-prem use a different call - is this correct?

 

I have given the workflow full permissions as outlined in all the articles, and have tried with a variety of urls (there seems to be a lot of debate on what needs to be in the url field), the same with template values (at the moment I'm just using sts, but have tried a variety of STS, STS#0, sts) all with the same result.

 

Does anyone have any ideas on what we need to do to get this things live? More than happy to use web request rather than a service call if that's what's needed.

 

I'm using Office 365/SharePoint Online and Nintex Standard 365.

icon

Best answer by kmcollins 19 June 2017, 03:52

View original

13 replies

Userlevel 7
Badge +17

Hi!

What I would suggest you is to try execute your web request using tools like Fiddler Composer or Postman‌. If you succeed there, using the same parameters, then you can start being worry However, from my experience, in O365 all calls (besides those requiring binary data) to the Sharepoint REST Service‌ endpoints are working.

The only thing you should try as well is to add, to your request's headers, the "cookie" header, containing FedAuth and rtFa‌ cookies' values. For testing purposes you can simply look into the Network tab of the Developer console, of your browser, and there you will find these cookies:

If you would like then to automate it, then you can follow guidelines from my post here: https://community.nintex.com/community/build-your-own/nintex-for-office-365/blog/2017/02/09/working-with-security-credentials-requestdigest-fedauth-rtfa

Regards,

Tomasz

Userlevel 2
Badge +5

Hi Tomasz,

I just figured out this morning how to test this with Postman (completely missed the raw option for body). I have also made a switch in the workflow to use a web request action rather than a http web service action. This produces a security issue - would this be resolved by supplying the above cookies?

When I use a http web service action, the response always tells me that the first parameter (regardless of what it is) does not exist in the method 'Add'. Which is the better action to use to create a site?

Userlevel 7
Badge +17

 I'm glad you figured it out. Do you succeeded creating site using Postman?

 Regarding your action: can you post a screen shot of the action's configuration.

On the other hand, why can't you use the "Office 365 Create Site" action? (http://help.nintex.com/en-US/o365/#o365/O365WorkFlow/WorkflowActions-INT/Office365CreateSite.htm?Highlight=create site)? 

 Regards,

 Tomasz

Userlevel 2
Badge +5

Hi Tomasz,

Yes, I can now create a site using Postman! I still can't get the workflow to create a site though. The parameters are all the same, and the web request action still produces a security error, and the HTTP web service action insists that parameters do not exist in the method 'Add'.

Is there something glaringly obvious I'm missing?

I would love to use the O365 action for this, but it's part of the enterprise license, and we only have standard

*Edit*

I started also receiving this error code: code: -2130575251, Microsoft.SharePoint.SPException for the web request. I looked it up and it means the protocol server requires a form digest but the form digest in the X-RequestDigest HTTP header is not as same as the one generated by the protocol server. 

Does anyone know how to resolve this issue?

Because I'm all out of ideas...and any help would be greatly appreciated!

Userlevel 7
Badge +17

Try using the FedAuth and rtFa cookies

Userlevel 2
Badge +5

Hi Tomasz,

I'm a little confused here - Postman can create a site with just request digest, why does Nintex need authentication cookies? 

Also, I thought providing a username/password for the web request action would generate authentication for the header?

*Edit* I tried running the workflow with X-requestdigest and FedAuth and rtFa cookies, the response was a straight up access denied.

Userlevel 7
Badge +17

That is veeeryyy odd.. But you are right - I confirm. Both using "Web Request" and "Call HTTP Web Service" actions I'm receiving access denied. No matter if I provide cookies or requestdigest token.

I have no time to verify if other REST calls work, eg. to create a list item or list itself, or to get file contents. IMHO this should really work. I see no reason why it does not (or stopped). Maybe there is something going on behind. Dunno.

I stuck. Please contact support@nintex.com and describe your problem. They should follow you up with a possible reason for such behavior, but this can take days (usually 2). To speed it up you can provide them with your exported workflow. Or take mine (it's a site workflow).

Regards,

Tomasz

Userlevel 7
Badge +17

ummm... I know it's a poor workaround, but maybe try with SharePoint Designer workflow or Microsoft Flow?

Regards,

Tomasz

Userlevel 2
Badge +5

Hi Thomasz,

I would use SharePoint designer, except running the same call there results in the below error:

{"error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"en-US","value":"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected."}}}

The same happens when I use a http web service call in Nintex. I have also been unable to resolve this issue. I don't suppose you would have any suggestions on this one?

Userlevel 2
Badge +5

Hi Tomasz,

Thanks for your help - I can confirm that at least create group and assign permission to group web requests are working. Those were not working until I gave the workflow app permission to the entire site collection, not just subsites and then they started to work. I thought the same would be true for create site, but it appears not. 

Kind regards,

Katherine

Userlevel 7
Badge +17

Please, look into an example I attached. There is also a "Call HTTP web service" action that s working (is returning 401 ).

I guess something is wrong with the JSON (or dictionary in case of Call HTTP and SharePoint Designer approaches)  - look into my example, you will find there how should be the dictionaries built.

Regards,

Tomasz

Userlevel 2
Badge +5

So, I have a solution to this issue:

The web request action wasn't working inside the app step. Remove the app step, and it now creates a site using exactly the same service call...go figure

Thanks to all for their help,

Katherine

Userlevel 7
Badge +17

 Weird... I was not using the app step. It didn't work in my case without  being inside the app step Maybe it was rather related to other kind of issue, and it was fixed in a meanwhile

Reply