Hi, I’m new in Elixir and studying it right now. Is there a way to consume an ASP.NET C# web service? I would gladly appreciate if you can assist me step by step.
See the HTTPoison library for making the requests.
Do you need to build query strings for it, or use a JSON body, or post a multipart form? The answer is still the same library, but if you’re more specific about what the web service looks like, people can give you more specific advice
you can also get away without an external dependency - Erlang’s built in
:httpc module is just fine for making http requests.
I tried using HTTPoison.get, however I do not know where to put the web method of the web service. As well as the parameter for that web service. Here’s the example of parameter to be sent to the web service:
By the way, I’m also new in web API, so pardoned me for the ignorance of technical terms used.
“Web method” is probably the URL, and the parameter you posted looks like it would be the body, with a content-type header of application/json. So build a URL with the web method, add the content type header, make a POST with that JSON as the body.
But really, we can only make educated guesses. Ultimately you can try our guesses, and they work, or you have to dig into the documentation of the target API more. (Feeling free of course to post follow-up questions if you don’t understand those docs.)
AFAIK ASP.NET web services use SOAP for communication, which is different from JSON. You can’t just pass the body on a request with the Posion library (maybe you can, I’m not certain about this)
The easiest way to do it is to use detergentex library. Check its read me, you basically need 3 things. The url, the web method and the parameters as a list.
I hope this helps
Hi guys. I was now able to consume the web service that I made using HTTPoison. I only lacked configuration of my web service in order to be called by a get request. Thanks for the help guys! I truly appreciate it.
I also read about detergentex in consuming API. I’ll take note of that. Will try that in future