How to consume Third Part API using Golang?

Please anyone guide me that how to consume API using Golang with user name and password?

This is the API address

if have to pass the following with request

request.Headers.Add(“Authorization”, "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(“username” + “:” + “password”)));

request.ContentType = “text/xml; encoding=‘utf-8’”;

request.Method = “Post”;

request.Headers.Add(“SOAPAction”, “”);

request.Host = “”;

I shall be very thankful to him.

What happens when you try what you posted? Do you get an error? If so, can you show us?


Actually, I confused how to pass user name and password with http.get and and I couldn’t found any solution for this.


I guess you should use some basic authentication like this:

client := &http.Client{}
req, err := http.NewRequest(<METHOD>, <URL>, nil)
req.SetBasicAuth(<user>, <password>)
res, err := client.Do(req)
if err != nil {
	<handle error here>
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.