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

Creating multiple fields programmatically with REST

$
0
0

Hi, can anyone tell me if its possible to 'POST' the creation of multiple fields (columns) using ajax REST call. At the moment, I can only POST one field at a time. I have tried the code below and it will only show the last field 'Field4'

ie

                               $.ajax({
                                        url:  metadatauri + "/fields",
                                        type: "POST",                 
                                        headers: {
                                            "accept": "application/json;odata=verbose",
                                            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                                            "X-Http-Method": "POST",
                                            "content-type": "application/json;odata=verbose"
                                        },                                  

                       data:JSON.stringify( {'__metadata': { 'type': 'SP.Field' }, 'Title': 'Field1', 'FieldTypeKind': 3 ,

                                                      '__metadata': { 'type': 'SP.Field' }, 'Title': 'Field2',  'FieldTypeKind': 3 ,

                                                        '__metadata': { 'type': 'SP.Field' }, 'Title': 'Field3', 'FieldTypeKind': 3 ,

                                                        '__metadata': { 'type': 'SP.Field' }, 'Title': 'Field4', 'FieldTypeKind': 3 ,

                                                        '__metadata': { 'type': 'SP.Field' }, 'Title': 'Field4', 'FieldTypeKind': 3 }),
                   
                                        success: function () {
                                        },
                                        error: function (err) {
                                                  alert(err);
                                        }
                              });       

Many thanks

Arty


Viewing all articles
Browse latest Browse all 7589

Trending Articles



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