0

I want to add item in sharepoint list using android but i could not found any sutaible example or solution, any one has ans for that? i tried this solution but its seem its does not work for me please give me some guidance.

__metadata:'type': 'SP.Data.SomeListItem'
 subject:'AnyThing'
 CommentDocumentName:'Data'
 comment:'add Docs'
 role:'Customer'
 AppID:'1234'
9
  • The REST API is the way to do this. The solution you cited is fine. What is your problem with that? Commented Jul 2, 2019 at 11:17
  • @Nils my issue it that when i sending all parameter using post i'm getting "The HTTP header Content-Type is missing or its value is invalid." do i need any other parameter to send? Commented Jul 2, 2019 at 12:10
  • my header is cookie:some value Accept:application/json;odata=verbose X-RequestDigest: some value Content-Type:application/json;odata=verbose Commented Jul 2, 2019 at 12:10
  • So the question is not "How do I use the SharePoint API", but rather "How do I send a valid content-type http-header in an android app"? Commented Jul 2, 2019 at 12:17
  • No question is valid i want to send the parameter from android if you have any or example how to update the share point list i tried in both way but first i just want to test in postman but its does not work its seems. Commented Jul 2, 2019 at 12:19

1 Answer 1

0

I can't speak "android", but using postman the following flow works for me:

Request "ContextInfo"

POST /_api/contextinfo HTTP/1.1
Host: my.sharepoint.local
Accept: application/json; odata=verbose
User-Agent: PostmanRuntime/7.15.0
Cache-Control: no-cache
Postman-Token: dac3ee21-85b6-4c86-8015-3bb9646e25a9,523b0e7b-7d02-4aee-b078-83af480696a1
Host: my.sharepoint.local
accept-encoding: gzip, deflate
content-length: 
Connection: keep-alive
cache-control: no-cache

which returns data.. i.e.:

{
    "d": {
        "GetContextWebInformation": {
            "__metadata": {
                "type": "SP.ContextWebInformation"
            },
            "FormDigestTimeoutSeconds": 1800,
            "FormDigestValue": "0x01524F8681FE5C746F329FA4CC040A709D0BCAFA2B6BA590397F40559C1787F314201BA81B0046F37CCF9C68282655AD042FC37B1A872670759B41FC9285FF3D,02 Jul 2019 13:03:18 -0000",
            "LibraryVersion": "16.0.4744.1000",
            "SiteFullUrl": "https://my.sharepoint.local",
            "SupportedSchemaVersions": {
                "__metadata": {
                    "type": "Collection(Edm.String)"
                },
                "results": [
                    "14.0.0.0",
                    "15.0.0.0"
                ]
            },
            "WebFullUrl": "https://my.sharepoint.local"
        }
    }
}

using that FormDigestValue as the X-RequestDigest in the next request:

POST /_api/web/lists/GetByTitle('Test')/items? HTTP/1.1
Host: my.sharepoint.local
Accept: application/json; odata=verbose
Content-Type: application/json
X-RequestDigest: 0x01524F8681FE5C746F329FA4CC040A709D0BCAFA2B6BA590397F40559C1787F314201BA81B0046F37CCF9C68282655AD042FC37B1A872670759B41FC9285FF3D,02 Jul 2019 13:03:18 -0000
User-Agent: PostmanRuntime/7.15.0
Cache-Control: no-cache
Postman-Token: 87735fcd-5f15-4f31-9b7e-62f5a3050b72,a798e358-5d14-4f26-9bfd-c50989850153
Host: my.sharepoint.local
accept-encoding: gzip, deflate
content-length: 29
Connection: keep-alive
cache-control: no-cache

 {
    'Title': 'New title' 
 }

Creates a new item in the list named Test.

7
  • for form digest value its worked its not worked for to add some content into target list for example if i need to add comment then i need to send parameter like comment as string type id as int of some other data this is not working. Commented Jul 2, 2019 at 13:17
  • Please post the list-json (i.e. the result of /_api/web/lists/GetByTitle('YourName')) and the post-data you are trying to send. I do not quite get what the problem seems to be. Commented Jul 2, 2019 at 13:22
  • ok i will try and let you know. Commented Jul 2, 2019 at 13:25
  • i just update the my queston with body value. please see that. Commented Jul 2, 2019 at 13:27
  • i have one dought using for digest these all value i need to send as header?? Commented Jul 2, 2019 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.