title: Amazon SP-API Update Inventory Stock
body: <p>i'm trying to update stocks of my inventory Amazon Catalog using SP-API.
  This is my code:</p>
  <pre><code>  private static IRestRequest CreateRequestFeedDocument()
     {
        IRestRequest restRequest = new RestRequest(&quot;feeds/2020-09-04/documents&quot;, Method.POST);
  
        AmazonInventory obj = new AmazonInventory();
        obj.SKU = &quot;GD4297-44&quot;;
        obj.Available = &quot;true&quot;;
        obj.Quantity = &quot;20&quot;;
        string xml = string.Empty;
  
        using (var stringwriter = new System.IO.StringWriter())
        {
           var serializer = new XmlSerializer(obj.GetType());
           serializer.Serialize(stringwriter, obj);
           xml = stringwriter.ToString();
        }
  
        restRequest.AddParameter(&quot;contentType&quot;, xml, ParameterType.RequestBody);
        restRequest.AddQueryParameter(&quot;MarketplaceIds&quot;, &quot;APJ6JRA9NG5V4,A1PA6795UKMFR9,A13V1IB3VIYZZH,A1805IZSGTT6HS,A1F83G8C2ARO7P,A1RKKUPIHCS9HS,A2NODRKZP88ZB9&quot;);
  
  
        AssumeRoleResponse assumeRoleResponse = null;
  
        Task.Run(async () =&gt;
        {
           assumeRoleResponse = await GetAssumeRoleTokenDetail();
        }).GetAwaiter().GetResult();
  
        // LWA credentials for app in amazon seller central
        var clientId = AmazonCredentials.Default.ClientId;
        var clientSecret = AmazonCredentials.Default.ClientSecret;
        // generate refresh token with 'Authorize' action for app in amazon seller central
        var refreshToken = AmazonCredentials.Default.RefreshToken;
  
        var lwaAuthCreds = new LWAAuthorizationCredentials
        {
           ClientId = clientId,
           ClientSecret = clientSecret,
           RefreshToken = refreshToken,
           Endpoint = new Uri(&quot;https://api.amazon.com/auth/o2/token&quot;)
        };
  
        restRequest = new LWAAuthorizationSigner(lwaAuthCreds).Sign(restRequest);
  
        var awsAuthCreds = new AWSAuthenticationCredentials
        {
           AccessKeyId = assumeRoleResponse.Credentials.AccessKeyId,
           SecretKey = assumeRoleResponse.Credentials.SecretAccessKey,
           Region = AmazonCredentials.Default.Region
        };
  
        restRequest.AddHeader(&quot;x-amz-security-token&quot;, assumeRoleResponse.Credentials.SessionToken);
  
        restRequest = new AWSSigV4Signer(awsAuthCreds)
           .Sign(restRequest, restClient.BaseUrl.Host);
  
        return restRequest;
     }
  
  restClient = new RestClient(live_url_base);
        IRestRequest restRequest = CreateRequestFeedDocument();
        var response = restClient.Execute(restRequest);
  </code></pre>
  <p>I get the following error</p>
  <pre><code>{
    &quot;errors&quot;: [
     { 
        &quot;code&quot;: &quot;InvalidInput&quot;,
        &quot;message&quot;: &quot;Invalid Input&quot;,
        &quot;details&quot;: &quot;&quot;
      }
     ]
  }
  </code></pre>
  <p>On the web I found this solution</p>
  <p>adding this line:</p>
  <pre><code>      restRequest.AddJsonBody(new { contentType = &quot;text/xml; charset=UTF-8&quot; });
  </code></pre>
  <p>I don't get Invalid inout error but I'm getting</p>
  <pre><code>&lt;Message&gt;The request signature we calculated does not match the signature you provided. Check your key and signing method.&lt;/Message&gt;
  </code></pre>
  <p>[![enter image description here][1]][1]</p>
  <p>Where I'm wrong?</p>
  <p>Thanks
  [1]: <a href="https://i.stack.imgur.com/kw5JC.png" rel="nofollow noreferrer">https://i.stack.imgur.com/kw5JC.png</a></p>