Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

SharePoint REST, create field and contenttype in Host Web

$
0
0

Hi, 

I have tried to provision fields and contenttypes to the hostweb but with no success. This is the code to provision the field:

    $.ajax(
        {
            url: appweburl + "/_api/SP.AppContextSite(@target)/web/fields?@target='" +
                hostweburl + "'",
            type: "POST",
            data: JSON.stringify({
                '__metadata': { 'type': 'SP.Field' }, 'FieldTypeKind': fieldType,
                'InternalName': fieldInternalName, 'Title': fieldDisplayName, 'Group': fieldGroup, 'Required': fieldRequired
            }),
            headers: {"accept": "application/json;odata=verbose","content-type": "application/json;odata=verbose","X-RequestDigest": $("#__REQUESTDIGEST").val()
            }

i have skipped the calback functions. i know that the problem is not in the appweburl or hostweburl variable, because i have used the same variables to provision a list with success.

the error message that i revieve is:

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"sv-SE","value":"Cannot convert a primitive value to the expected type 'Edm.Int32'. See the inner exception for more details."}}}



Viewing all articles
Browse latest Browse all 8089

Trending Articles



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