Sonia
Sonia

Reputation: 21

UFT API authentication

I need help with setting up Authentication for soap webservice, I'm using UFT 12.02, I've tried following steps >>Properties / Event / BeforeApplyProtocolSettings / New Handler then typed below code:

public void StServiceCallActivity4_OnBeforeApplyProtocolSettings(object sender, HP.ST.Ext.WebServicesActivities.Models.StChannelsBindingStack args) { //string myAuth = "Basic" + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("username:password")); this.StServiceCallActivity4.HttpRequestHeaders.Add("Authorization","Basic QUNOOmllMkM1RzZiczgNCg==");

    }

I don't know what I'm doing wrong,I'm getting "401 : Unauthorized".(I used same user name and password in SOAPUI and it worked fine.)

Thanks

Upvotes: 0

Views: 1397

Answers (1)

Sonia
Sonia

Reputation: 21

I found out what I was doing wrong, In the snippet " string myAuth = "Basic" + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("username:password")); " I added space after Basic word("Basic ") and it worked fine.Full code isstring myAuth = "Basic " + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("username:password")); this.StServiceCallActivity4.HttpRequestHeaders.Add("Authorization",myAuth);

Upvotes: 1

Related Questions