Creating anonymous access links through REST API

%3CLINGO-SUB%20id%3D%22lingo-sub-145937%22%20slang%3D%22en-US%22%3ECreating%20anonymous%20access%20links%20through%20REST%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-145937%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Guys%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20trying%20to%20generate%20an%20anonymous%20access%20link%20for%20a%20document%20(ideally%20looking%20to%20do%20for%20a%20list%20item%20too%20-%20as%20a%20separate%20point%20if%20anyone%20knows%20how).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20wanting%20to%20run%20this%20REST%20query%20in%20a%20Flow%20but%20at%20the%20moment%20i'm%20just%20testing%20in%20Postman%20locally.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECan't%20for%20the%20life%20of%20me%20get%20it%20working%2C%20I%20keep%20getting%20an%20'Operation%20is%20not%20valid%20due%20to%20the%20current%20state%20of%20the%20object'%20error.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnonymous%20sharing%20is%20enabled%20on%20the%20site%20etc.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20the%20REST%20Query%20i'm%20using%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPOST%20%2Fsites%2Ftestsite%2F_api%2FSP.Web.CreateAnonymousLink%20HTTP%2F1.1%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EHost%3A%26nbsp%3Bmytenant.com%3CBR%20%2F%3EAuthorization%3A%20Bearer%20%3CBR%20%2F%3EContent-Type%3A%20application%2Fjson%3CBR%20%2F%3EAccept%3A%20application%2Fjson%3Bodata%3Dverbose%3CBR%20%2F%3EX-RequestDigest%3A%200xF881520BE117765765358087E00A4FD6071E1A1E0C6EEBD79E6174B02FCC63A40E2D7891B009EB8FB08DABB99371ACA63DBDF272B2C1660E4DA3ADE847FD6AFD%2C17%20Jan%202018%2015%3A13%3A13%20-0000%3CBR%20%2F%3ECache-Control%3A%20no-cache%3CBR%20%2F%3EPostman-Token%3A%20c62b45ae-097e-5c63-a4ef-c5771030f61b%3C%2FP%3E%0A%3CP%3E%7B'url'%3A%20'https%3A%2F%2Ftenant%2Fsites%2Fsite%2FAppointment%20Forms%2FAppointment%20form%20example.docx'%2C%20'isEditLink'%3A%20true%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOriginally%20I%20didn't%20have%20a%20Request%20digest%20-%20I%20did%20a%20POST%20to%20contextinfo%20and%20copied%20the%20value%20from%20here.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIs%20it%20just%20not%20supported%20outside%20of%20a%20SharePoint%20page%3F%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHoping%20someone%20can%20help%20shed%20some%20light!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-307250%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20anonymous%20access%20links%20through%20REST%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-307250%22%20slang%3D%22en-US%22%3E%3CP%3EI%20realize%20this%20is%20pretty%20old%2C%20but%20did%20you%20make%20any%20progress%3F%26nbsp%3B%20I%20am%20having%20a%20similar%20problem%2C%20just%20trying%20to%20get%20it%20running%20in%20Postman.%26nbsp%3B%20A%20query%20to%20the%20search%20api%20works%20fine%20in%20another%20Postman%20tab%2C%20using%20the%20same%20Bearer%20token.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F64316iA2DCC14FF90AF1C9%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22SS.png%22%20title%3D%22SS.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F64317iED872FBA96A19957%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22SS1.png%22%20title%3D%22SS1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

Hi Guys,

 

I'm trying to generate an anonymous access link for a document (ideally looking to do for a list item too - as a separate point if anyone knows how).

 

I'm wanting to run this REST query in a Flow but at the moment i'm just testing in Postman locally.

 

Can't for the life of me get it working, I keep getting an 'Operation is not valid due to the current state of the object' error.

 

Anonymous sharing is enabled on the site etc.

 

This is the REST Query i'm using:

 

POST /sites/testsite/_api/SP.Web.CreateAnonymousLink HTTP/1.1


Host: mytenant.com
Authorization: Bearer
Content-Type: application/json
Accept: application/json;odata=verbose
X-RequestDigest: 0xF881520BE117765765358087E00A4FD6071E1A1E0C6EEBD79E6174B02FCC63A40E2D7891B009EB8FB08DABB99371ACA63DBDF272B2C1660E4DA3ADE847FD6AFD,17 Jan 2018 15:13:13 -0000
Cache-Control: no-cache
Postman-Token: c62b45ae-097e-5c63-a4ef-c5771030f61b

{'url': 'https://tenant/sites/site/Appointment Forms/Appointment form example.docx', 'isEditLink': true}

 

Originally I didn't have a Request digest - I did a POST to contextinfo and copied the value from here.

 

Is it just not supported outside of a SharePoint page??

 

Hoping someone can help shed some light!

 

Thanks

 

1 Reply
Highlighted

I realize this is pretty old, but did you make any progress?  I am having a similar problem, just trying to get it running in Postman.  A query to the search api works fine in another Postman tab, using the same Bearer token.

 

SS.pngSS1.png