Create Sharepoint Entry in a list using REST api

0
Hello all, I need your help to create a Sharepoint Entry in a list using REST api. I think I did everything correctly but I still get en ‘BAD request’ error… Here is what I do: I get a token from https://accounts.accesscontrol.windows.net; the token I get is correct because I’m able to get the content of the list with it I get the Entity type of the items of my list using a get REST API and the URL: https://<mysite>.sharepoint.com/sites/MD/_api/web/lists/GetByTitle('<MyList>')?$select=ListItemEntityTypeFullName I get the X-RequestDigest value using a REST API (POST) and the URL: https://<mysite>.sharepoint.com/sites/MD/_api/contextinfo I try to create an entry in the list using a REST API (POST) and the URL:  https://<mysite>.sharepoint.com/sites/MD/_api/web/lists/GetByTitle('<MyList>')/items   in the HTTP headers tab of the “Call REST” activity, i have: Authorization: the token I got from the first point Accept: 'application/json;odata=verbose' Content-Type: 'application/json;odata=verbose' X-RequestDigest: the X-RequestDigest value I got in the point 3   in the request tab, I have the body of my request: '{ "__metadata": { "type": "' + $EntityType/ListItemEntityTypeFullName + '" }, "Title": "TheTitle", "CC_x0020_Name": "TheName", "CC_x0020_Description": "TheDesc", "CC_x0020_Responsible": "TheResponsible", "Departement": "TheDepartement", "Department_x0020_Name": "TheDepartementName" }' In the microflow, everything works fine: I get a token, I get the Entity type, I get the X-RequestDigest but the creation of the item doesn’t work and I get the following error: com.mendix.modules.microflowengine.MicroflowException 400: Bad Request at Sharepoint.SHP_CreateCC (CallRest : 'Call REST (POST)') at Sharepoint.GetCostCenters.nested.8bcdacef-17b8-4518-935d-1e5cf0ce3b7f [214 of 216] (SubMicroflow : 'SHP_CreateCC') at Sharepoint.GetCostCenters (NestedLoopedMicroflow : '') ... Do you know what is wrong ????   For information, here is how an item looks like in sharepoint: <?xml version="1.0" encoding="utf-8"?> <feed xml:base="https://mysite.sharepoint.com/sites/MD/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"> <id>d7069216-70ce-430d-acac-6e4aa2a16f0f</id> <title /> <updated>2022-02-14T08:04:50Z</updated> <entry m:etag="&quot;1&quot;"> <id>b5eb946f-ba4c-4622-aa61-dcdca4ea858d</id> <category term="SP.Data.MyListListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> <link rel="edit" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject" type="application/atom+xml;type=entry" title="FirstUniqueAncestorSecurableObject" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/FirstUniqueAncestorSecurableObject" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments" type="application/atom+xml;type=feed" title="RoleAssignments" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/RoleAssignments" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles" type="application/atom+xml;type=feed" title="AttachmentFiles" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/AttachmentFiles" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType" type="application/atom+xml;type=entry" title="ContentType" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/ContentType" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/GetDlpPolicyTip" type="application/atom+xml;type=entry" title="GetDlpPolicyTip" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/GetDlpPolicyTip" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml" type="application/atom+xml;type=entry" title="FieldValuesAsHtml" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/FieldValuesAsHtml" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText" type="application/atom+xml;type=entry" title="FieldValuesAsText" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/FieldValuesAsText" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit" type="application/atom+xml;type=entry" title="FieldValuesForEdit" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/FieldValuesForEdit" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/File" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/Folder" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/LikedByInformation" type="application/atom+xml;type=entry" title="LikedByInformation" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/LikedByInformation" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList" type="application/atom+xml;type=entry" title="ParentList" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/ParentList" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Properties" type="application/atom+xml;type=entry" title="Properties" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/Properties" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Versions" type="application/atom+xml;type=feed" title="Versions" href="Web/Lists(guid'f91e17d9-8003-473a-9fc5-e97ccc0c2049')/Items(1)/Versions" /> <title /> <updated>2022-02-14T08:04:50Z</updated> <author> <name /> </author> <content type="application/xml"> <m:properties> <d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType> <d:Id m:type="Edm.Int32">1</d:Id> <d:ServerRedirectedEmbedUri m:null="true" /> <d:ServerRedirectedEmbedUrl/> <d:Title>TheTitle/d:Title> <d:CC_x0020_Name>TheName</d:CC_x0020_Name> <d:CC_x0020_Description>TheDescription</d:CC_x0020_Description> <d:CC_x0020_Responsible>MyResponsible</d:CC_x0020_Responsible> <d:Department>TheDepartment</d:Department> <d:Department_x0020_Name>TheDepartmentName</d:Department_x0020_Name> <d:ID m:type="Edm.Int32">1</d:ID> <d:ContentTypeId>0x0100BA3D138B18D67248B1364BED9A6CC4FE00AFADE015A59BD244ADFDC8D999CC7D21</d:ContentTypeId> <d:Modified m:type="Edm.DateTime">2022-02-14T07:56:12Z</d:Modified> <d:Created m:type="Edm.DateTime">2022-02-14T07:56:12Z</d:Created> <d:AuthorId m:type="Edm.Int32">28</d:AuthorId> <d:EditorId m:type="Edm.Int32">28</d:EditorId> <d:OData__UIVersionString>1.0</d:OData__UIVersionString> <d:Attachments m:type="Edm.Boolean">false</d:Attachments> <d:GUID m:type="Edm.Guid">36ccf786-0dc3-4304-a44c-922bb0e33c16</d:GUID> <d:ComplianceAssetId m:null="true" /> </m:properties> </content> </entry> </feed>  
asked
2 answers
3

Problem solved…

in the body, I had “Departement” instead of “Department”…

shame on me...

 

answered
0

In the request tab you need to escape the opening braces if I’m not wrong.

 

Maybe if you replace all ‘{‘ with ‘{{‘ it will work.

answered