activex not working - WeOnlyDo Discussion board

activex not working (wodHttpDLX)

by tomer, Tuesday, April 16, 2024, 09:57 (199 days ago)

Hi

I have a code that works in vba

Dim httpRequest
Set httpRequest = CreateObject("MSXML2.ServerXMLHTTP.6.0")

httpRequest.SetOption 2, 13056

httpRequest.Open "POST", tokenUri, True

httpRequest.setRequestHeader "AUTHORIZATION:", "BASIC ZjM1MGIyNGIwOWQ2NTRkZDd"

httpRequest.setRequestHeader "Content-Type:", "application/x-www-form-urlencoded"

httpRequest.Send tokenRequestBody

Do While httpRequest.readyState <> 4

DoEvents
httpRequest.waitForResponse (1)
Loop


Debug.Print httpRequest.status
Debug.Print httpRequest.responseText

i want to use activex and i'm not getting the same result

wodHttpDLX1.URL = tokenUri

wodHttpDLX1.Request.Headers.Add "AUTHORIZATION", "BASIC ZjM1MGIyNGIwOWQ2NTRkZDd"
wodHttpDLX1.Request.Headers.Add "Content-Type", "application/x-www-form-urlencoded"

wodHttpDLX1.Post tokenRequestBody

Debug.Print wodHttpDLX1.Response.StatusCode
Debug.Print wodHttpDLX1.Response.Body

activex not working

by Jasmine, Tuesday, April 16, 2024, 21:02 (198 days ago) @ tomer

Hi,

where do you set Http.Request.Body? I see you use 'Post' method, but not with the URL. If you check our helpfile

https://www.weonlydo.com/HttpDLX/Help/wodHttpDLX-object-Post-method.html

argument in Post is not body contents, but the URL.

Can you try to change that and then let me know if it's ok.

Regards,
Jasmine

activex not working

by tomer, Wednesday, April 17, 2024, 08:40 (198 days ago) @ Jasmine

I changed it and now i'm getting an empty response

wodHttpDLX1.Request.Headers.Add "AUTHORIZATION", "BASIC ZjM1MGIyNGIwOWQ2NTRkZ"

wodHttpDLX1.Request.Headers.Add "Content-Type", "application/x-www-form-urlencoded"

wodHttpDLX1.Hostname = "https://openapi.taxes.gov.il"

wodHttpDLX1.Request.Body = tokenRequestBody

wodHttpDLX1.Post "/shaam/tsandbox/longtimetoken/oauth2/token"

msgBox wodHttpDLX1.Response.StatusCode
msgBox wodHttpDLX1.Response.Body

What is the problem?

activex not working

by Jasmine, Wednesday, April 17, 2024, 17:20 (197 days ago) @ tomer

Hi.

We can't know what is the problem since we don't know what you're doing. We can help with HTTP protocol, but not with the actual contents you send.

I suggest you 'spy' what is sent/received by working component, and then check what's sent/received with wodHttpDLX. You can use DebugFile property to get full conversation between client and server, and then check what's different.

I don't know what is in your 'tokenRequestBody' and how it is formatted, what is expected on remote side etc.. So I can't really help with functioning of your code in terms of registration with the app on the server.

Jasmine

activex not working

by tomer, Wednesday, April 17, 2024, 19:02 (197 days ago) @ Jasmine

Hi

I don't have a problem with the content. The same content is working with MSXML2.ServerXMLHTTP.6.0 Object
I have a problem with wodHttpDLX parameters

Complete Working Code:

Dim httpRequest
Set httpRequest = CreateObject("MSXML2.ServerXMLHTTP.6.0")

httpRequest.SetOption 2, 13056

httpRequest.Open "POST", "https://openapi.taxes.gov.il/shaam/tsandbir/longtimetoken/oauth2/token", True

httpRequest.setRequestHeader "AUTHORIZATION:", "BASIC ZjM1MGIyNGIwOWQ2NTRkZD="

httpRequest.setRequestHeader "Content-Type:", "application/x-www-form-urlencoded"

httpRequest.Send "grant_type=authorization_code&code=AAN-BzaeOhP-"

Do While httpRequest.readyState <> 4
httpRequest.waitForResponse (1)
Loop

msgBox httpRequest.status

msgBox httpRequest.responseText

Not Working:

wodHttpDLX1.Hostname = "https://openapi.taxes.gov.il"

wodHttpDLX1.Request.Headers.Add "AUTHORIZATION:", "BASIC ZjM1MGIyNGIwOWQ2NTRkZD="

wodHttpDLX1.Request.Headers.Add "Content-Type", "application/x-www-form-urlencoded"

wodHttpDLX1.Request.Body ="grant_type=authorization_code&code=AAN-BzaeOhP-"

wodHttpDLX1.Post "/shaam/tsandbir/longtimetoken/oauth2/token"

msgBox wodHttpDLX1.Response.StatusCode
msgBox wodHttpDLX1.Response.Body

[image]

activex not working

by tomer, Wednesday, April 17, 2024, 19:18 (197 days ago) @ tomer

I just want to add

this code from one of your samples doesn't work

I'm getting status = 0 and empty response


wodHttpDLX1.Hostname = "http://www.weonlydo.com"
wodHttpDLX1.Request.FormPost.Add "Username", "joe"
wodHttpDLX1.Request.FormPost.Add "Password", "joe"
wodHttpDLX1.Post "/HttpDLX/Demo/TestFormPost.asp"
msgBox wodHttpDLX1.Response.StatusCode
msgBox wodHttpDLX1.Response.Body

activex not working

by Jasmine, Wednesday, April 17, 2024, 21:07 (197 days ago) @ tomer

Hi.

I don't thikn you can use "http" or "https" in the hostname, you shold use it in URL, or in Post method. Note that URL property is overwritten with your Post argument. You should have get errors related ot it. If you use component in a scripting environment, make sure you set Http1.Blocking = True

Let me know what happens with your sample (or our sample...) with Http1.Blocking = true (possibly needed for your environment) and using full URL in Post method.

Don't use Hostname property at all.

Jasmine

activex not working

by tomer, Thursday, April 18, 2024, 08:47 (197 days ago) @ Jasmine

Great now it's working!

The correct code:

wodHttpDLX1.URL = "http://www.weonlydo.com/HttpDLX/Demo/TestFormPost.asp"
wodHttpDLX1.Blocking = True
wodHttpDLX1.Request.Headers.Add "Username", "joe"
wodHttpDLX1.Request.Headers.Add "Password", "joe"
wodHttpDLX1.Post
msgBox wodHttpDLX1.Response.StatusCode
msgBox wodHttpDLX1.Response.Body