cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute a SP2013 REST API request with Nintex Workflow

Automation Master
Automation Master
44 91 54K

How to execute a SP2013 REST API request with Nintex Workflow

With all the Nintex Workflow actions, we can achieve lots of great workflows. Sometimes, we'd like to build more complicated, technical, reusable workflows. For these workflows, we need more actions and possibilities that can be achieved by calling SharePoint ASMX web services or SP2013 REST API requests.

As the ASMX web services are deprecated in SharePoint 2013 and SharePoint Online, it is recommended to use SP2013 REST API instead when it is possible (not all functionalities of the ASMX web services are available in SP2013 REST API).

I'd like to help you building your SP2013 REST API requests.

There are two categories of SP2013 REST API requests :

  • POST : to update, create or remove information in SharePoint,
  • GET : to retrieve information from SharePoint.

The process to execute these two types of requests is different.

How to execute a GET request

To execute a GET request, a "Web request" action only is needed. The configuration of the action should look like this :

REST_API_Request_GET.png

It is possible to select a text variable in the "Store result in" field to get the response of the request and then use a "Query XML" action to extract the information needed.

How to execute a POST request

The execution of a POST request is more complex. A request digest is first needed in order to pass the security information to the server when sending the POST request.

To get the request digest, the following "Web request" action should be executed :

REST_API_Request_Digest.png

A text variable has to be selected in the "Store result in" field.

Then the request digest has to be extracted from the response of the request.

To extract this information, a "Query XML" action has to be configured to execute the following XPath query :

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

QueryXML_extract_request_digest.png

Once the request digest is stored in a variable, it is possible to execute the POST request via a "Web request" configured like the following :

REST_API_Request_POST.png

Example : How to update a list item using REST API

Before executing the POST request used to update a list item, the request digest and the list item entity type full name are needed.

To get the request digest, follow the steps explained above.

To get the list item entity type full name, execute the following "Web request" action (where "txtListName" is the title of the list where the list item to update is) :

rest_api_get_listitementitytypefullname.png

The next step is to extract the list item entity type full name from the response of the above request using the following XPath query :

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

The last step is to execute the POST request with the following "Web request" action (where "numID" is the id of the item to update) :

rest_api_update_item.png

I hope that this will help the community !

Caroline Jung

91 Comments
cweipipf
Nintex Newbie

Hi all,

did anybody of you tried to update the metadata of a document in a document library with REST Webservice in a Nintex Workflow?

I did create a workflow and it works fine with the syntax of the article above - except for the managed metadata column. This column is always ignored by the web service. Is there any other Syntax compared to a list item??

Automation Master
Automation Master

Hi Christof,

To update a managed metadata field, the body of your request should look like this :

{

     '__metadata': {'type':'yourListItemEntityTypeFullName'},

     'yourManagedMetadataColumnName': {

          '__metadata': {'type':'SP.Taxonomy.TaxonomyFieldValue'},

          'Label':'YourTermLabel',

          'TermGuid':'YourTermGuid',

          'WssId':id

     }

}

As far as I know, updating a multiple managed metadata field using SP2013 REST API is currently not supported. I use the "Update multiple items" action in Nintex Workflow using the following field value:

FirstTermId;#FirstTermLabel|FirstTermGuid;#SecondTermId;#SecondTermLabel|SecondTermGuid

Hope this helps

cweipipf
Nintex Newbie

Hi Caroline,

thanks for your post.

I use exactly the syntax you posted. But on my environment it only works for list items, not for documents in a document library. Do you have other experiences? Does this syntax works for documents on your System?

Best regards

Christof

Automation Master
Automation Master
surya250
Nintex Newbie

hi Need help create global navigation in SharePoint on prime using nintex workflow + Rest api

The 'Accept' header must be modified using the appropriate property or method.

Parameter name: name

I am getting this error

Automation Master
Automation Master

You can try to execute your web request without the "Accept" header that you've added.

Hope this helps

surya250
Nintex Newbie

Yes its working thanks your help .

vayinapurapu
Nintex Newbie

Does this work in Nintex Workflow online?

Automation Master
Automation Master

Yes it works in Nintex Workflow online. I've just noticed that building Json request body (when performing POST requests) is a bit tricky. I've explained a workaround here :

https://community.nintex.com/message/34252?commentID=34252#comment-34390

Hope this helps

labasmuse
Nintex Newbie

Hi Caroline,

thank you very much for this great article about how to execute a SP2013 REST API request with Nintex Workflow.

I tried to execute your post request code. However the workflow throws an System.UnauthorizedAccessException in the first action by trying to get the contextinfo. In the SharePoint Environment we use ADFS and premise (SharePoint Enterprise2016). I used the normal login credentials (active Directory) for authentication. The user has site collection administrator permission on the site where the list workflow executes.

Fehler beim Ausführen der Webanforderung. <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-2147024891, System.UnauthorizedAccessException</m:code><m:message xml:lang="de-DE">Z

Maybe you can give me a hint.

Thank you and kind regards

Andy

vayinapurapu
Nintex Newbie

Andy,

Good Morning! I am not sure the settings in SP2016. Did you have any thing in Site features called "Workflow Can use App Permissions". if it is, Try activating that feature. Looks like the workflow is not able to read due to insufficient permissions.

Thanks,

Vinay.

Automation Master
Automation Master

Hi Andreas,

To get the complete error message, you can send you an email in Plain text mode with the error message which you can store in a variable in Error Handling section of the Web request action. You can also test your web request in Nintex Workflow editor, when configuring the web request action, you can click on "Run now" button in the ribbon. It will simulate the execution of the web request.

Can you then share the complete error message you get?

Have a nice day

terekg
Nintex Newbie

Hi Caroline,

Does this work for creating a document set automatically from a list item? I've been trying to figure out how to get this to happen and it kind of sounds like I would use a REST API to accomplish it but I'm not quite sure how.

kmcollins
Nintex Newbie

Hi Caroline,

I'm hoping you can help me out - I'm trying to use a web request action in 365 to create a subsite, I have provided the X-RequestDigest value, but am still receiving the The security validation for this page is invalid and might be corrupted error. Is there something else I need to do (other than to give the workflow app full permission) that can resolve this issue?

Secondly, how did you manage to enter content straight into the web request action? Anytime I do that, the workflow suspends with 'Request body cannot be empty'. 

 

Thanks,
Katherine 

Automation Master
Automation Master

Hi Katherine,

Regarding the security issue, can you send to yourself via the workflow the value of the request digest that you provide in the query?

There's nothing else to perform regarding security.

In O365, it's a bit tricky to be able to build the body of the web request. I've described in this discussion how to do it:

https://community.nintex.com/message/34286#comment-34390

Hope this helps

Automation Master
Automation Master

Hi Terek,

I haven't tried to, but it seems possible using listdata.svc:

https://sharepoint.stackexchange.com/questions/114882/is-it-possible-to-create-a-document-set-using-...

It should be possible to perform the query from a workflow using the web request.

Tell me if you managed to create a document set with the web request action.

kmcollins
Nintex Newbie

Hi Caroline,

I've got the workflow logging the request digest value, and emailing me the authenticated header (content type, accept and request digest) in an email. Although, I thought if I used web request and provided an email and password it would create the authentication for the header?

I've just run a test without the username and password and received an 'access denied' message. I have however, managed to add the body of the request straight into the action which makes it a little easier to see what's going on. 

Thanks for your help

jose_fidalgo
Nintex Newbie

Hello,

I have a list that has a field called "codroject".
When this field is filled the workflow should update the commitemnets field of one other list in another site
.

I need create web request to do this.

Who do this?

Automation Master
Automation Master

Hi Katherine,

Great that you managed to build the body . Regarding authentication, did you finally make it working?

Is the request digest value in the correct format?

The request to perform to get the request digest has to be a POST one and not GET.

I maybe forgot to mention that usename and password are mandatory otherwise the web request won't work.

Have a nice day,

Caroline

Automation Master
Automation Master

Hi Jose,

You can follow the example written in this blog post to update a list item.

Tell me if you have issues or problems.

Hope this helps

kmcollins
Nintex Newbie

Hi Caroline,

I still can't get it to work - I've got the request digest as part of the header for the web request, the request digest is in the same format I used during testing for site creation using Postman. The workflow app has elevated permissions and the web request action is in an app step. There's a username and password added to the action. 

Is there anything else for authentication that I need to include? Would it be better to run this using the call http web service action?

Automation Master
Automation Master

Hi Katherine,

Can you send me the url that you've populated in the web request, the headers you've added and the body?

Then it will be easier for me to give you advices.

If you're using SharePoint REST API, then http web service action won't work.

kmcollins
Nintex Newbie

Hi Caroline,

The web request: https://<tenant>.sharepoint.com/sites/<sitecollection>/_api/web/webinfos/add

Method: Post

Header:

Content-Type: application/json;odata=verbose

Accept: application/json;odata=verbose

X-RequestDigest: (calculated by the workflow) e.g.: 0x7B2DCD41DA731F0B58ED0CE2F7677469F897E46A31E386319C49C812AD3E19B1D96CD6500C71F9BF3487706DDBE26C8605E7679285681FC90E97BF0F0A78D871,13 Jun 2017 06:43:02 -0000

Body:

{"parameters": "Url": "choc","Title":"choc - Chocolate","Description": "created by workflow","Language": 1033,"WebTemplate": "STS#0","UseUniquePermissions": true}}

 

Thanks for your help - I'm way out of ideas

Automation Master
Automation Master

Hi Katherine,

There are few things missing in the body.

Can you try with the following body (I've underlined missing caracters)?

{"parameters": { '__metadata': {'type': 'SP.WebInfoCreationInformation' },"Url": "choc","Title":"choc - Chocolate","Description": "created by workflow","Language": 1033,"WebTemplate": "STS#0","UseUniquePermissions": true}}

I hope it will work

kunal_soni
Nintex Newbie

Hey Caroline,

I have followed the same steps as you mentioned here for GET request. I got the XML response from web request as below:

Response status code: 200

Response content:
<?xml version="1.0" encoding="utf-8"?><entry xml:base="http://brvm153:45438/sites/devs/tb/_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" m:etag="&quot;2&quot;"><id>d8d7b397-ba4c-48ac-8e1e-474c4fcb3a8b</id><category term="SP.Data.UserList2ListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject" type="application/atom+xml;type=entry" title="FirstUniqueAncestorSecurableObject" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/FirstUniqueAncestorSecurableObject" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments" type="application/atom+xml;type=feed" title="RoleAssignments" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/RoleAssignments" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles" type="application/atom+xml;type=feed" title="AttachmentFiles" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/AttachmentFiles" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType" type="application/atom+xml;type=entry" title="ContentType" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/ContentType" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml" type="application/atom+xml;type=entry" title="FieldValuesAsHtml" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/FieldValuesAsHtml" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText" type="application/atom+xml;type=entry" title="FieldValuesAsText" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/FieldValuesAsText" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit" type="application/atom+xml;type=entry" title="FieldValuesForEdit" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/FieldValuesForEdit" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/File" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/Folder" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList" type="application/atom+xml;type=entry" title="ParentList" href="Web/Lists(guid'1ba7f9ac-9097-438d-b079-9677419b0917')/Items(9)/ParentList" /><title /><updated>2017-06-13T12:08:59Z</updated><author><name /></author><content type="application/xml"><mSmiley Tongueroperties><d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType><d:Id m:type="Edm.Int32">9</d:Id><d:ContentTypeId>0x010046DB9F9D7073D346A45596CDAB523B8A</d:ContentTypeId><d:Title m:null="true" /><d:EventsId m:type="Edm.Int32">6</d:EventsId><d:Employee_x0020_Name>Raj</d:Employee_x0020_Name><d:Employee_x0020_Email>raj@vol.com</d:Employee_x0020_Email><d:No_x002e__x0020_of_x0020_Guests m:type="Edm.Double">567</d:No_x002e__x0020_of_x0020_Guests><dSmiley Very Happyietary_x0020_restrictions>&lt;div class="ExternalClass19FEE4156E8A451EB9E052C78EB40793"&gt;&lt;p&gt;non-vol&lt;/p&gt;&lt;/div&gt;</dSmiley Very Happyietary_x0020_restrictions><d:Volunteer_x0020_Events>&lt;div class="ExternalClass8DC76AA6EC7643928AEE26A459CD4143"&gt;&lt;p&gt;Guj&lt;/p&gt;&lt;/div&gt;</d:Volunteer_x0020_Events><d:T_x002d_shirt_x0020_Size m:type="Edm.Double">20</d:T_x002d_shirt_x0020_Size><d:Business_x0020_Unit>3</d:Business_x0020_Unit><d:No_x002e__x0020_of_x0020_tickets m:type="Edm.Double">56</d:No_x002e__x0020_of_x0020_tickets><d:Volunter_x0020_EvntsId m:type="Edm.Int32">2</d:Volunter_x0020_EvntsId><dSmiley Very HappyeleteEv m:null="true" /><d:Archivin m:null="true" /><dSmiley SurprisedData__dlc_ExpireDate m:type="Edm.DateTime">2017-03-21T11:10:03Z</dSmiley SurprisedData__dlc_ExpireDate><d:Test m:type="Edm.DateTime">2017-03-18T18:30:00Z</d:Test><dSmiley FrustratedharePoi m:type="Edm.Int32">5</dSmiley FrustratedharePoi><d:ID m:type="Edm.Int32">9</d:ID><d:Modified m:type="Edm.DateTime">2017-03-20T10:44:44Z</d:Modified><d:Created m:type="Edm.DateTime">2017-03-20T10:44:44Z</d:Created><d:AuthorId m:type="Edm.Int32">1</d:AuthorId><d:EditorId m:type="Edm.Int32">1</d:EditorId><dSmiley SurprisedData__UIVersionString>1.0</dSmiley SurprisedData__UIVersionString><d:Attachments m:type="Edm.Boolean">false</d:Attachments><d:GUID m:type="Edm.Guid">0174edce-3aa7-445c-a5b9-1845aaa58068</d:GUID></mSmiley Tongueroperties></content></entry>

When I use this XML in Query XML action I am getting XPATH as :
/defaultNS:entry/defaultNS:content/defaultNS:mSmiley Tongueroperties/defaultNS:d:Employee_x0020_Name

The problem is this is not working as expected (as shown in scree-shot in blog). It does not return me the name of the employee but returns me same XML.

Kindly guide me where I am going wrong.

I am using SharePoint on-premises

kunal_soni
Nintex Newbie

Hi Sorav,
I have sane problem as of yours. Can you please share your answer to me like what type of changes you made.

kmcollins
Nintex Newbie

Hi Caroline,

Oh, yes, until this afternoon I had the metadata parameter, and it produced the same error. I removed this afternoon after reading something online, and I thought it would work...but it didn't

Thanks,

Katherine

Automation Master
Automation Master

Can you try with the following XPath query?

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

kunal_soni
Nintex Newbie

Hi,
I have tried this but its not working.

I am attaching the screen-shot of the result.

It is giving back XML

Automation Master
Automation Master

Hi,

Is your XML beginning with "Response status code: 200 Response content:" or with "<?xml version="1.0" encoding="utf-8"?><entry xml:base="http://brvm153:45438/sites/devs/tb/_api/""?

It should begin with "<?xml version="1.0" encoding="utf-8"?><entry xml:base="http://brvm153:45438/sites/devs/tb/_api/""

I hope it will work

Automation Master
Automation Master

Hi Katherine,

Can you remove "Accept" header and try again?

Regarding "Content-type" header, is it the header automatically added when you select POST method?

kmcollins
Nintex Newbie

Hi Caroline,

I removed the accept header and received this error message:

<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-2130575251, Microsoft.SharePoint.SPException</m:code><m:message xml:lang="en-US">The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again.

Yes, the content-type header is automatically added (and required) when you select the POST method. 

*Edit* I have noticed in the response header the first line is: ["Transfer-Encoding=chunked","Cache-Control=private, max-age=0","Content-Type=application\/json;odata=verbose;charset=utf-8","Expires=Tue, 30 May 2017 07:04:49 GMT","Last-Modified=Wed, 14 Jun 2017 07:04:49 GMT". Could that first date be causing all these issues?

I was just wondering - is there another way to create a subsite without using the 'create site' action?

Thanks,
Katherine

kunal_soni
Nintex Newbie

No my xml starts with <?xml version="1.0" encoding="utf-8"?><entry xml:base="http://brvm153:45438/sites/devs/tb/_api/

kunal_soni
Nintex Newbie

Hi Caroline,

I have check my XML start with same string as you say. I doubt it can be environment difference. Mine is SharePoint 2013 on- premise version. Can you please share your environment. If you need more details regarding my environment configuration then I can be reached at my email-id. I would be really happy to get more help.

Automation Master
Automation Master

Hi Katherine,

I think that the error message that you received is due to the request digest. Which url do you use to get the request digest?

I don't know any other way of creating a subsite without the "create site" action, sorry.

There's another url that you can use but it's almost the same that you've used :

{Workflow Context:Current site URL}‍/_api/web/webs/add

With the exact same headers but the following body (you can add the description as well) :

{ 'parameters': { '__metadata':{ 'type': 'SP.WebCreationInformation' }, 'Title':'Created From WF','Url':'createdwf', 'WebTemplate':'STS#0', 'UseSamePermissionsAsParentSite':true } }

Hope this helps

Automation Master
Automation Master

Hi Kunal,

Can you share with me the whole XML you're using to test the XPath query?

You're right, it can't be due to an environment difference and there's no specific configuration that can alter the proper functioning of this action.

kmcollins
Nintex Newbie

Hi Caroline,

I didn't think there was another way...but just in case I thought it better to ask.

Unfortunately, this produces the same error as /web/webinfos/add. Could it be possible that this is an error with Nintex/SharePoint?

Thank you for your time and help

kmcollins
Nintex Newbie

Hi Caroline,

Thanks for your help - it wasn't working within the App Step action. I took it out of the app step, and it now works

Katherine

Automation Master
Automation Master

Hi Katherine,

Thanks a lot for your feedback !

That's good to know

I'm glad that you could finally get your workflow working .

Have a nice day,

Caroline

joseph_cervi
Nintex Newbie

Caroline,

I was able to build a Nintex Workflow to permanently delete content (bypass recycle bin) using this post as a baseline.

Many thanks to you,

-JC

Automation Master
Automation Master

Hi Joseph,

Thanks for your feedback, I'm really happy that this blog can help !

Have a nice day,

Caroline Jung

dleathrum
Nintex Newbie

Hello,

I am trying to follow your example here, but I am having some difficulties following your variables.  Are the variables listed with txt in front variables or columns?  Along with what does the num_ID have to be in your example?  Just something to differentiate the item?  And is webURL just a variable that contains the URL of the API you are getting info from?

Thank you,

Duncan

Automation Master
Automation Master

WebURL is a common property supplied by the Nintex actions themselves and gives you the current web address.

I would imagine the workflow variables called txt... are single line of text variables and have been named in that way so that you can see quickly what type they are.

Automation Master
Automation Master

You're absolutely right Cassy I have the habit to prefix variable names with something that help me identifying the type of the variable.

WebUrl is the reference that you can find in "Common" tab when adding a reference and correspond to the absolute url of the current web site.

In my example, "numID" is a workflow variable where the list item id of an item is stored.

Don't hesitate if you have other questions

nubeus3r
Nintex Newbie


I am trying to remove an external users permissions from a document with a post request

I was able to get the Request Digest, however when I try to do a post request ‌to /_api/SP.Sharing.DocumentSharingManager.UpdateDocumentSharingInfo I get the following error
‌{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Not well formatted JSON stream."}}}

I think the issue is to do with the body, which I have built up into a single variable.
{'resourceAddress':'https://xxx.sharepoint.com/sites/xxx/xxx/xxx.docx','userRoleAssignments':[{'__metadata':{'type':'SP.Sharing.UserRoleAssignment'},'Role':'0','UserId','xxx@xxx.com'}],'validateExistingPermissions':false,'additiveMode':false,'sendServerManagedNotification':false,'customMessage':'','includeAnonymousLinksInNotification':false}

I have tried single quotes, double quotes, escaping the quotes, but I get the following error message.
{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Not well formatted JSON stream."}}}

I have verified that the following does work in javascript
var data = "{\"resourceAddress\":\"https://xxx.sharepoint.com/sites/xxx/xxx/xxx.docx\",\"userRoleAssignments\":[{\"__metadata\":{\"type\":\"SP.Sharing.UserRoleAssignment\"},\"Role\":\"0\",\"UserId\":\"xxx@xxx.com\"}],\"validateExistingPermissions\":false,\"additiveMode\":false,\"sendServerManagedNotification\":false,\"customMessage\":\"\",\"includeAnonymousLinksInNotification\":false}";"

Any help would be greatly appreciated

Automation Master
Automation Master

Are you using Nintex for O365 or Nintex for SharePoint Onpremise?

nubeus3r
Nintex Newbie

Thanks for your response. It was for Nintex for O365. I re-created a new web request with the same configuration and that seemed to do the trick. There was nothing wrong with the body variable after all. Thanks again

Automation Master
Automation Master

Great, I'm glad that you could find a solution to your problem

leannarh
Nintex Newbie

Caroline,

Thank you so much for the information.  I was able to use it to create an item in a list on a different site with the Web request action, and then update a column in the new item.  I also need to add any attachments from the original list item to the new item, but haven't found the right combination of URL, headers and json to make it work however.  Any help you could give me would be most appreciated.

I have it working so the file name is attached to the new item, but if you open that attachment, it just shows you a small x, so it doesn't look like the actual file was attached.  By the way, I am doing this cross-domain.

My URL looks like this:

<website>/_api/web/Lists/getByTitle('HotWorkPermitsFromExternal')/items(54)/AttachmentFiles/add(FileName='1503678393715584089584.jpg')

The content type is application/json;odata=verbose

I have Headers of X-RequestDigest with a value of the digest request you explained how to get,

and IF-MATCH with a value of *

Automation Master
Automation Master

I'm glad that this blog has helped you .

Regarding list item attachments, here's the documentation to retrieve list item attachments (one request for the properties such as the file name and one request for the file content using $value) and to add new attachments:

https://dev.office.com/sharepoint/docs/sp-add-ins/working-with-folders-and-files-with-rest#FileAttac...

You could retrieve attached files from one list item and based on information you've retrieved you could create attachments to the other list item.

Hope this helps