Link to home
Start Free TrialLog in
Avatar of esak2000
esak2000

asked on

convert curl to c# code

How do I convert the following curl code to c#?


curl -X POST -H "Content-type: application/json" -H "Authorization: BeGlobal apiKey=<YOUR API KEY>" -d '{"text":"Hello Developers", "from":"eng", "to":"fra"}' https://api.beglobal.com/translate

Open in new window

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

It is unlikely that you will be able to duplicate cURL functions in C# but you can apparently link to 'libcurl.dll' which does the important work.  This page has a link to a project ( http://thedotnetframework.blogspot.com/2008/06/lets-talk-about-http-protocol-and-http.html ) and some info about using the dlls.  http://stackoverflow.com/questions/4925057/libcurl-dll-problem-with-curl-and-c-sharp-net
ASKER CERTIFIED SOLUTION
Avatar of esak2000
esak2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Before you try to connect to an API, try to use a simple cURL procedure that just GETs a web page to make sure the basic code and dlls are working.
Avatar of esak2000
esak2000

ASKER

The above code worked, the authorization was something that needed to be worked on with the provider's API