Please anyone guide me that how to consume API using Golang with user name and password?
This is the API address
https://emea.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/AirService
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 = “travelport.com”;
I shall be very thankful to him.
skillian
(Sean Killian)
2
What happens when you try what you posted? Do you get an error? If so, can you show us?
Hi,
Actually, I confused how to pass user name and password with http.get and http.post and I couldn’t found any solution for this.
Thanks
geosoft1
(George Calianu)
4
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
system
(system)
Closed
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.