Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.misc > #463 > unrolled thread
| Started by | Rob <gbzrope@gmail.com> |
|---|---|
| First post | 2019-01-22 13:28 +0000 |
| Last post | 2019-03-02 21:31 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.basic.misc
WinHTTP problems Rob <gbzrope@gmail.com> - 2019-01-22 13:28 +0000
Re: WinHTTP problems Wolfgang Εnzinger <we_usenet@nurfuerspam.de> - 2019-02-16 23:56 +0100
Re: WinHTTP problems Wolfgang Εnzinger <we_usenet@nurfuerspam.de> - 2019-02-17 00:12 +0100
Re: WinHTTP problems Wolfgang Εnzinger <we_usenet@nurfuerspam.de> - 2019-03-02 21:31 +0100
| From | Rob <gbzrope@gmail.com> |
|---|---|
| Date | 2019-01-22 13:28 +0000 |
| Subject | WinHTTP problems |
| Message-ID | <VA.000000b6.4f005841@gmail.com> |
I have a *large* legacy program written in VB6, Very successfull,
works fine on all flavours of Windows up to and including 10
Now I need to communicate with a third party using TML Basic Auth and
JSON.
SO far I have created some short code to test the communications:
Dim HttpReq As New WinHttp.WinHttpRequest
HttpReq.SetCredentials "<username>", "<password>", 0
HttpReq.Open "PUT", "https://<API URL>", False
HttpReq.setRequestHeader "Content-Type", "application/json"
HttpReq.Send " "
HttpReq.Send "GET https://<API URL>"
Both the Send methods result in:
{
"status": "error",
"code": 401,
"message": "Access denied"
}
The sane credentials do work OK in Postman app.
What am I missing or doing wrong please?
[toc] | [next] | [standalone]
| From | Wolfgang Εnzinger <we_usenet@nurfuerspam.de> |
|---|---|
| Date | 2019-02-16 23:56 +0100 |
| Message-ID | <o18oq1rchq56.dlg@weu.my-fqdn.de> |
| In reply to | #463 |
Hi Rob,
not sure why you use "PUT" in the .Open method when a "GET" is what you
actually have in mind, and also what
> HttpReq.Send " "
is intended for.
Try like this, this works fine here:
Dim HttpReq As WinHttp.WinHttpRequest
Set HttpReq = New WinHttp.WinHttpRequest
HttpReq.Open "GET", "https://www.abc.com/xyz/index.html"
HttpReq.SetCredentials "<username>, "<password>", 0&
HttpReq.Send "GET /xyz/index.html"
Debug.Print HttpReq.ResponseText
HTH Wolfgang
Am Tue, 22 Jan 2019 13:28:44 -0000 schrieb Rob:
> I have a *large* legacy program written in VB6, Very successfull,
> works fine on all flavours of Windows up to and including 10
>
> Now I need to communicate with a third party using TML Basic Auth and
> JSON.
>
> SO far I have created some short code to test the communications:
>
> Dim HttpReq As New WinHttp.WinHttpRequest
>
> HttpReq.SetCredentials "<username>", "<password>", 0
>
>
> HttpReq.Open "PUT", "https://<API URL>", False
>
>
> HttpReq.setRequestHeader "Content-Type", "application/json"
>
> HttpReq.Send " "
>
> HttpReq.Send "GET https://<API URL>"
>
> Both the Send methods result in:
> {
> "status": "error",
> "code": 401,
> "message": "Access denied"
> }
>
>
> The sane credentials do work OK in Postman app.
>
> What am I missing or doing wrong please?
[toc] | [prev] | [next] | [standalone]
| From | Wolfgang Εnzinger <we_usenet@nurfuerspam.de> |
|---|---|
| Date | 2019-02-17 00:12 +0100 |
| Message-ID | <16oabxcf99vba$.dlg@weu.my-fqdn.de> |
| In reply to | #465 |
Am Sat, 16 Feb 2019 23:56:56 +0100 schrieb Wolfgang Εnzinger:
> Dim HttpReq As WinHttp.WinHttpRequest
> Set HttpReq = New WinHttp.WinHttpRequest
> HttpReq.Open "GET", "https://www.abc.com/xyz/index.html"
> HttpReq.SetCredentials "<username>, "<password>", 0&
> HttpReq.Send "GET /xyz/index.html"
The parameter ("GET /xyz/index.html") is redundant here,
>> HttpReq.Send
instead would be sufficient.
> Debug.Print HttpReq.ResponseText
HTH Wolfgang
[toc] | [prev] | [next] | [standalone]
| From | Wolfgang Εnzinger <we_usenet@nurfuerspam.de> |
|---|---|
| Date | 2019-03-02 21:31 +0100 |
| Message-ID | <g2rmmzkmk0az.dlg@weu.my-fqdn.de> |
| In reply to | #465 |
Am Sat, 16 Feb 2019 23:56:56 +0100 schrieb Wolfgang Εnzinger: > Try like this, this works fine here: Code now archived at http://rosettacode.org/wiki/HTTPS/Authenticated#Visual_Basic :-)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.basic.misc
csiph-web