cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
mirian_navas
Nintex Newbie

Create SharePoint Group with Contribute permissions

Jump to solution

 

 

I Followeb the blog Create SharePoint Group with Contribute permissions but I received an error when I call Query XML.

 

Group1.png

The Digest Token variable is:

{"d":{"GetContextWebInformation":{"__metadata":{"type":"SP.ContextWebInformation"},"FormDigestTimeoutSeconds":1800,"FormDigestValue":"0x6A9282CB6D5AF6D75CDAFDBD2D4B4617968675505F540AC7965E48D67746A965983370BF20046CC0A0504BD133A93F573F2D1ABEF8944A40FD206E2E73856BFA,03 Apr 2019 10:48:44 -0000","LibraryVersion":"16.0.8720.1224","SiteFullUrl":"https://server.sharepoint.com/sites/poc","SupportedSchemaVersions":{"__metadata":{"type":"Collection(Edm.String)"},"results":["14.0.0.0","15.0.0.0"]},"WebFullUrl":"https://server.sharepoint.com/sites/poc/nintex"}}}

On the "web request" action I use the user with domain

Group2.png

If I remove the domain in the username, the error is on web request action:

Digest Token: {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}

The initiator and the user specify in the web request are site collection administrators.

Any idea how to solve this?

 

 

 

Labels: (1)
0 Kudos
Reply
13 Replies
Automation Master
Automation Master

Re: Create SharePoint Group with Contribute permissions

Jump to solution

can you show the Query XML action, as that is where the error is occuring?

0 Kudos
Reply
mirian_navas
Nintex Newbie

Re: Create SharePoint Group with Contribute permissions

Jump to solution
This is the action that shows the error, but maybe the web request response is already wrong
Untitled3.png
0 Kudos
Reply
mirian_navas
Nintex Newbie

Re: Create SharePoint Group with Contribute permissions

Jump to solution

The first error is on the "Query XML" action where we try to read the object "FormDigestValue". I have changed this action by dictionaries to get the value as indicated in this post: how to parse json data in nintex workflow for office 365

 

Now, when I call to ‌/_api/web/sitegroups using "Call HTTP Web Service" action received "BadRequest"

0 Kudos
Reply
Automation Master
Automation Master

Re: Create SharePoint Group with Contribute permissions

Jump to solution

I'm confused on your response. When does which error occur? You made a change, but what was the result?

 

It looks like your attempt to get the digest worked fine. If it didn't you would have received an unauthorized error, but in your image of the history a digest is there and you quoted a value that has the digest. So that doesn't seem to be the issue.

0 Kudos
Reply
mirian_navas
Nintex Newbie

Re: Create SharePoint Group with Contribute permissions

Jump to solution

The first problem was to obtain the digest value using query XML but I resolved them using dictionaries.

Now, when I call Call HTTP Web Service ({Workflow Context:Current site URL}‌/_api/web/sitegroups)  to create the group the result is " Bad request" 

 

CreateGroupIssue1.pngCreateGroupIssue2.png

0 Kudos
Reply
nico
Nintex Newbie

Re: Create SharePoint Group with Contribute permissions

Jump to solution

Hi,

For your first post, you receive this error ("XML content is invalide .....") because the return of your WebService is in JSON. So you pass JSON to the action "query XML", and that's why you got this error. 

 

In you action, you specify the header : "Accept" : "application/json;odata=verbose", with this you say : "I want the result of this query in JSON format"

You just have to Remove your Header "Accept", and your result will be in XML format. (by default, the /_api/contextinfo will return XML format)

Like : 

GetDigest.png

 

 

In your action query XML, you can use this XPath to get the Digest: 

//*[local-name()='FormDigestValue']

 

 

For your secund error, 

I think you error is in your content, may be it's not well formated.

 

To query this REST end point, you must at least have in your header

"content-type""application/json; odata=verbose" 

"Accept": "application/json;odata=verbose",
"X-RequestDigest":"......."

 

And in your content : 

{
            "__metadata": {
                "type": "SP.Group"
            },
            "Title": "groupName",
            "Description": "group desc"

}

 

0 Kudos
Reply
mirian_navas
Nintex Newbie

Re: Create SharePoint Group with Contribute permissions

Jump to solution

@nico wrote:

...

For your secund error, 

I think you error is in your content, may be it's not well formated.

 

To query this REST end point, you must at least have in your header

"content-type""application/json; odata=verbose" 

"Accept": "application/json;odata=verbose",
"X-RequestDigest":"......."

 

And in your content : 

{
            "__metadata": {
                "type": "SP.Group"
            },
            "Title": "groupName",
            "Description": "group desc"

}

 


Thanks a lot @nico but the second part continues to fail.

Headers.png

 

Metadata.png

parameters.png

 

WebSdervice.png

And the result is:

Result.png

According to the post I followed, it is not necessary to specify any parameters for the creation of the group.

Any idea what is missing?
Thank you

0 Kudos
Reply
nico
Nintex Newbie

Re: Create SharePoint Group with Contribute permissions

Jump to solution

I don't see the error too ...

 

May be nintex build and pass your parameter with a wrong format (the "request content"). 

Have you try to use the "web request" action (instead of a "call http web ervice") and pass your JSON in the "body" of your request ? (and not use build dictionnary to create your JSON)

 

0 Kudos
Reply
mirian_navas
Nintex Newbie

Re: Create SharePoint Group with Contribute permissions

Jump to solution

Hi @nico 

I used "web request" and pass my JSON on the body directly and the result is bad with different text

Screenshot_1.png

Screenshot_2.png

@fhunthAny idea? 

 

0 Kudos
Reply