Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

REST Request To Create "Link To Document" Content Type Item in Document Library

$
0
0

I added the "Link to Document" content type to my document library, and then tried to "upload a link" (create an item) in the document library using a REST request. I have no problem uploading actual files (Content Type: Document) as items using REST requests, but I am new to creating the link.

The main properties of the jQuery Ajax object used in the request (url, method, data [body]) are below.

The HTTP response is 200.

The name column in the library item is what it is in the 'url' property of the request, so I seem to have that right.

But the Content Type is actually "Document" and not "Link to Document", so there is something wrong with my body part of the POST request. What it is creating is a simple text (Notepad-readable) document with the text of the body (JSON object string). Note that I took the 'type' property from a REST request read (get) of an actual Link To Document content type item in the library. I am guessing the other stuff.  Perhaps the method is supposed to be something other than "POST"??

url: https://mdsd/_api/web/getFolderByServerRelativeUrl('/DEV Master Docs')/Files/add(url='<name column text data>',overwrite=true)?$expand=ListItemAllFields,
method: "POST",
body: "{ '__metadata' : { 'type':'SP.FieldUrlValue' },'url':'" + theUrl + "' }",


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>