I am trying to update a list item in sharepoint. I am using the code below it returns Bad Request. any idea Thanks in advance...

Hanna Nassar Nassar 1 Reputation point
string cont = "{ '__metadata': { 'type': 'SP.IssuesListItem' }, 'Status': 'Close'}";
var content = new StringContent(cont, Encoding.UTF8, "application/json");
string url = "https://mywebsite.com/_api/web/lists/GetByTitle('tasks')/items?$filter=ID eq 932"

var credential = new System.Net.NetworkCredential(

            using (var handler = new HttpClientHandler() { Credentials = credential, UseProxy = false })
                using (var client = new HttpClient(handler))


                    client.DefaultRequestHeaders.Add("X-HTTP-Method", "MERGE");
                    var mediaType = new MediaTypeWithQualityHeaderValue("application/json");
                    mediaType.Parameters.Add(new NameValueHeaderValue("odata", "nometadata"));
                    client.DefaultRequestHeaders.Add("X-RequestDigest", await GetRequestDigest());
                    client.DefaultRequestHeaders.Add("binaryStringRequestBody", "true");
                    client.DefaultRequestHeaders.Add("IF-MATCH", "*");

                    HttpResponseMessage response = await client.PostAsync(url, content);
                    return true;
A set of technologies in the .NET Framework for building web applications and XML web services.
2,581 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,995 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
1,686 questions
No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Peter Fleischer (Freelancer) 17,571 Reputation points

    did you convert your password to SecureString?

     string pwString = "password";
     System.Security.SecureString pwSecure = new System.Security.SecureString();
     foreach (var c in pwString) pwSecure.AppendChar(c);
     var credential = new System.Net.NetworkCredential(
    No comments

  2. Michal Tech 1 Reputation point

    To simply write to one blank NFC tag, make sure all of these options are unchecked. Finally, select “Write” at the bottom of the screen and tap the back of your phone write my paper help to a blank NFC tag as if you were going to read it. This writes the URL to the tag. Congratulations, you've just encoded your first NFC tag!

    No comments

  3. Bruce (SqlWork.com) 28,196 Reputation points

    you are using the lookup url instead of the update url:

    POST https://{site_url}/_api/web/lists(guid'{list_guid}')   
    Authorization: "Bearer " + accessToken   
    Accept: "application/json;odata=verbose"   
    Content-Type: "application/json"   
    Content-Length: {length of request body as integer}   
    If-Match: "{etag or *}"   
    X-HTTP-Method: "MERGE"   
    X-RequestDigest: "{form_digest_value}"   
      "__metadata": {   
        "type": "SP.List"   
      "Title": "New title"   

    the lookup should give you the guid. also it looks like you are using basic authentication. be sure this is supported. if its onprem or hosted vm you are probably good. but online Sharepoint will not support basic

    No comments