title: How to upload image to LinkedIn for Ugc image post in C#
body: <p>So I am following <a href="https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin#creating-a-share-on-linkedin" rel="nofollow noreferrer">Linkedin Documentation</a> for implementing Create Image Share on Linkedin.</p>
  
  <p>The documentation lists three steps:</p>
  
  <ol>
  <li>Register your image to be uploaded.</li>
  <li>Upload your image to LinkedIn.</li>
  <li>Create the image share.</li>
  </ol>
  
  <p>While I am able to do the first step to get the <em>uploadUrl</em>, I am getting 400 response error with blank error message while doing step 2.</p>
  
  <p>The documentation list the second step as: </p>
  
  <pre><code>curl -i --upload-file /Users/peter/Desktop/superneatimage.png --header "Authorization: Bearer redacted" 'https://api.linkedin.com/mediaUpload/C5522AQGTYER3k3ByHQ/feedshare-uploadedImage/0?ca=vector_feedshare&amp;cn=uploads&amp;m=AQJbrN86Zm265gAAAWemyz2pxPSgONtBiZdchrgG872QltnfYjnMdb2j3A&amp;app=1953784&amp;sync=0&amp;v=beta&amp;ut=2H-IhpbfXrRow1'
  </code></pre>
  
  <p>Here's my step 2 in C# code:</p>
  
  <pre><code>private bool UploadImageBinaryFile(RequestUploadUrlResponse uploadDetails)
      {
          using (HttpClient client = new HttpClient())
          {
              client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", #access_token#);
              client.DefaultRequestHeaders.Add("X-Restli-Protocol-Version", "2.0.0");
              MultipartFormDataContent form = new MultipartFormDataContent();
              string fileAddress = image_path + "image.png";
              byte[] fileBytes = File.ReadAllBytes(fileAddress);
              string name = "upload-file";
              form.Add(new ByteArrayContent(fileBytes), name);
              HttpResponseMessage response = client.PutAsync
                  (
                      uploadDetails.value.uploadMechanism.mediaUploadHttpRequest.uploadUrl,
                      form
              ).Result;
  
              if (response.IsSuccessStatusCode)//&lt;--getting 400 error Bad Request here
              {
                  string responseBody = response.Content.ReadAsStringAsync().Result;
                  return true;
              }
              else
              {
                  ErrorResponseHandler(response.Content.ReadAsStringAsync().Result);
                  return false;
              }
          }
      }
  </code></pre>
  
  <p>I have ensured that I was successfully able to the uploadUrl from the first step. And when I used the URL <a href="https://api.linkedin.com/v2/assets/" rel="nofollow noreferrer">https://api.linkedin.com/v2/assets/</a><em>#id#</em> to check the status, I was able the see the status as <em>WAITING_UPLOAD</em>.</p>
  
  <p>Where am I going wrong?</p>