-2

I am new to API. Can someone help me how to pass following request through HttpWebRequest and get response?

curl -F 'file=@/home/user/Documents/Invoice_Attachments_File.pdf' 
https://api.fortnox.se/3/inbox\?path\=inbox_kf \
-H "Access-Token: accesstoken" \
-H "Client-Secret: secret"

I wonder how to pass arguments like :

curl -F 'file=@/home/user/Documents/Invoice_Attachments_File.pdf' 

I have following so far but it does not work:

var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.fortnox.se/3/inbox/");
httpWebRequest.ContentType = "application/xml";
httpWebRequest.Accept = "application/xml";
httpWebRequest.Method = "PUT";
httpWebRequest.Headers.Add("Authorization-Code", "accesstoken");
httpWebRequest.Headers.Add("Client-Secret", "secret");
mrd
  • 2,095
  • 6
  • 23
  • 48

1 Answers1

0

You didn't send any request to server. You just created it. Consider to use code below.

WebResponse response = request.GetResponse();

Anyway, you should provide much more information about the problem you stuck.

Have fun.

Ozan Topal
  • 127
  • 1
  • 1
  • 11
  • I have changed a bit of my question. I wonder how to use pass header like :curl -F 'file=@/home/user/Documents/Invoice_Attachments_File.pdf' – mrd Feb 10 '20 at 10:28
  • I missed attachment part of the curl. https://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data check this url out. – Ozan Topal Feb 10 '20 at 10:34