Jump to content
Software FX Community

webservice requiring authentication


richbon
 Share

Recommended Posts

I have to access a webservice that requires a user to authenticate with a username and password.  How do I do that?

Simply using this:

invoke-webservice -WSDL https://example.com/_vti_bin/QueryData.asmx?wsdl

returns:

Invoke-WebService : The remote server returned an error: (401) Unauthorized.

I can't be the first person to need to do this, but I've spent the afternoon searching this forum and the web and I can't find anything that seems to apply to my situation.  I couldn't find anything in PowerGadgets Creator, either.

Can anyone point me in the right direction?  Thanks! 

-Rich 

 

Link to comment
Share on other sites

Thanks for the reply, but it doesn't seem to be working for me for some reason.  I can create the credential fine, but then it still gives me this error:

Invoke-WebService : The remote server returned an error: (401) Unauthorized.
At line:1 char:18
+ invoke-webservice  <<<< -credential $cred -WSDL https://example.com/_vti_bin/QueryData.asmx?wsdl

Now, I know definitely the account I'm using works, because I can open the link in IE and get the whole wsdl definitions and operations list.

Any other thoughts?  This would be perfect if we could get it working.

-Rich 

 

Link to comment
Share on other sites

Can I try it somehow?  I don't know of a 'public' webservice requiring authentication that I can test.  Do you have any strange characters in your username or password?  Maybe there's some kind of problem with the string passed...

Otherwise, I might be able to whip a test up if I can borrow some C# code online to create my own webservice...

Link to comment
Share on other sites

I asked our developer, and he said it's using Basic authentication.

Of note: in IE, I can use DOMAIN\username or just username and both versions work.  Neither version works with invoke-webservice.

There are no strange characters in the username or password - just letters (upper and lower case) and numbers.

Also, I don't know if it matters, but notice that the webservice is using https.

-Rich

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...