0

I am new to SharePoint App. I have created one app with CRUD operations. While I try to insert data I am getting following error


Message from webpage

{"readyState":4,"responseText":"{\"error\":{\"code\":\"-2146232832, Microsoft.SharePoint.SPException\",\"message\":{\"lang\":\"en-US\",\"value\":\"Failed to create a list item for this external list based on the Entity (External Content Type) 'tblBillingPoints' in EntityNamespace 'TimeSheetModel'. Details: Message from External System : 'Forbidden'.\"}}}","status":500,"statusText":"error"}

OK

My code is as below:

create: function (bid, billing) {
       // alert(_spPageContextInfo.webServerRelativeUrl);
        $.ajax({
            url: _spPageContextInfo.webServerRelativeUrl +
                        "/_api/web/lists/getByTitle('tblBillingPoints')/items",
            type: "POST",
            contentType: "application/json;odata=verbose",
            data: JSON.stringify(
                {
                    '__metadata': {
                        'type': 'SP.Data.TblBillingPointsListItem'
                    },
                    'ID': bid,
                    'BillingPoint': billing
                }),
            headers: {
                "accept": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            },
            success: function () {
                REST.FormFiller.clear();
            },
            error: function (err) {
                alert(JSON.stringify(err));
            }
        });
    }

Could you please help me to solve this issue?

0

You cannot set the ID column of a SharePoint list item. It is a default column for which SharePoint generates Ids internally since they have to be unique.

If you want to store the value of 'bid' variable somewhere, you will have to create another custom column to store it.

  • Thanks Vardhaman for your reply, I modified code as "create: function (hid, hname) {$.ajax({url: _spPageContextInfo.webServerRelativeUrl +"/_api/web/lists/getByTitle('tblHolidays')/items",type: "POST",contentType: "application/json;odata=verbose",data: JSON.stringify({'__metadata': {'type': 'SP.Data.TblHolidaysListItem'},'HID': hid,'HDesc': hname}),headers: {"accept": "application/json;odata=verbose","X-RequestDigest": $("#__REQUESTDIGEST").val()},success: function () {REST.FormFiller.clear();},error: function (err) {alert(JSON.stringify(err));}});}". Still I have the same issue. Please help. – guru Aug 4 '13 at 10:03
  • Please add more details to your question. 1) Is the list tblBillingPoints in your app web or your host web? 2) Is it an external list? – Vardhaman Deshpande Aug 4 '13 at 10:52
  • It is sharepoint hosted app. I am trying to update information to SQL table. My table tblBillingPoints has field as "ID". I don't want to change the field name. So, I created another method with table "tblHolidays". – guru Aug 4 '13 at 14:52
  • Thanks again. I really appreciate your prompt response. It is sharepoint hosted app. I am trying to update information to SQL table. My table tblBillingPoints has field as "ID". I don't want to change the field name in the existing table. So, I created new table "tblHolidays" with HID, and HName for this CRUD operation. – guru Aug 4 '13 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.