Skip to main content
Nintex Community Menu Bar

I tried to create .ps1 file to document library by "Web Request" action but it didn't work.

May I know what’s wrong with my workflow? Thanks!

 

First, I get the Digest value.

URL: https://mysharepoint.com/my_site/_api/contextinfo

 

Then, the create action:

URL: https://mysharepoint.com/my_site/_api/web/GetFolderByServerRelativeUrl('Testing_Document')/Files/add(url='Testing.ps1', overwrite=true)

 

Result:

 

Hi ​@Norman Choi,

This post is in the Nintex for Office 365 section, but based on the screenshots, it appears to be SharePoint on-premise. Is that correct?

Looking at the post, it appears that you may be missing some headers.
The headers should be:
!--scriptorstartfragment-->

  -H "Authorization: Bearer {access_token}" \

  -H "Accept: application/json;odata=verbose" \

  -H "Content-Type: application/octet-stream" \

  -H "X-RequestDigest: {FormDigestValue}" \

!--scriptorendfragment-->

The second issue may be the file.
Is this an existing file, or is it just an empty file you are creating?

Have you tested this in an API testing tool such as Postman, and if so, does it work there?


Hi ​@Norman Choi 
Have you solved your issue? 


Hi ​@Norman Choi,

This post is in the Nintex for Office 365 section, but based on the screenshots, it appears to be SharePoint on-premise. Is that correct?

Looking at the post, it appears that you may be missing some headers.
The headers should be:
!--scriptorstartfragment-->

  -H "Authorization: Bearer {access_token}" \

  -H "Accept: application/json;odata=verbose" \

  -H "Content-Type: application/octet-stream" \

  -H "X-RequestDigest: {FormDigestValue}" \

!--scriptorendfragment-->

The second issue may be the file.
Is this an existing file, or is it just an empty file you are creating?

Have you tested this in an API testing tool such as Postman, and if so, does it work there?

Yes, it is on-premise version. I would like to create the empty file. I tested this in Postman also doesn’t work.

Finally, I use the “Create item” action to create the .docx file, then using “Web Request” with “PUT” method to make a .ps1 file. Thanks!


Hi ​@Norman Choi 
Have you solved your issue? 

It has been solved now. Thanks!