0

I want to run a curl request given as

curl --data-binary @"/path/to/my.pdf" -H "Content-Type: application/pdf" -L "http://pdfx.cs.man.ac.uk"

This request simply sends a PDF file to http://pdfx.cs.man.ac.uk and in response this site return a XML file. How it can be done in C#?

9
  • What did you try to run it, you can just run that - what specifically did you want to achieve? Commented Nov 30, 2016 at 15:00
  • You've got to create a process and execute the command from within the process. Check out askubuntu.com/questions/506985/… Commented Nov 30, 2016 at 15:02
  • Process.Start maybe? Commented Nov 30, 2016 at 15:02
  • 1
    Have you looked at the WebRequest, WebClient, or HttpClient classes in .NET? Commented Nov 30, 2016 at 15:03
  • 1
    @ShahbazAhmadSahi that didnt answer what I said one tiny tiny bit Commented Nov 30, 2016 at 15:08

1 Answer 1

1

If I understand correctly, you want to reproduce form POST action in C#. One way is to use HttpClient from this package (.NET 4.0) or directly if working in .NET 4.5+.

A fully working example can be found here. Basically you have to:

  • you initialize the http client
  • initialize form data
  • post the data
  • wait for the response

You can also set the content type of posted content (in your case application/pdf), by following the provided answer from this question.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.