Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer parameters - how to? #2

Closed
RibeyeOnTheBone opened this issue Jun 15, 2013 · 3 comments
Closed

Integer parameters - how to? #2

RibeyeOnTheBone opened this issue Jun 15, 2013 · 3 comments

Comments

@RibeyeOnTheBone
Copy link

Tim,

Thanks for writing Excel-Rest, I am finding it great.

I have run into an issue, I hope you can point me in the right direction.

I want to set a parameter that is an integer, but

postRequest.AddParameter "myInteger", myInteger

gives a ByRef type compile error, since postRequest is expecting strings as parameters.

If I pass myInteger as a string the web service says it cant convert test to number.

I see you have an example of

postRequest.AddParameter "myInteger", 20

This compiles for me also (dont understand how this can work, but I have stopped asking "why" questions of Microsoft) but obviously a hard coded value is only useful in some cases.

Can you advise how to set a non string parameter?

@timhall
Copy link
Member

timhall commented Jun 15, 2013

Good question Greg, let me see if I can modify the source to be a little more flexible with the parameters that are accepted. My guess is that quotes are being added to your integer value when it is sent to your service and that's why it's being rejected. I could see this being an issue with Double and Boolean as well so I'll see if I can adjust it for all of those cases.

With the library expecting strings, it will currently convert your parameter to the following for a POST request: "myInteger":"20", which is not the desired behavior. Instead it should be "myInteger":20 so this is definitely something missing from the library and I'll add it right away.

@timhall
Copy link
Member

timhall commented Jun 15, 2013

I've updated the RestRequest class to allow Variant parameters for AddParameter() and AddQuerystringParameter() and have successfully tried it with the following example:

Dim PostRequest As New RestRequest
PostRequest.Method = httpPOST

PostRequest.AddParameter "Integer", 20
PostRequest.AddParameter "Double", 3.14
PostRequest.AddParameter "Boolean", True

Debug.Print PostRequest.Body
' -> {"Integer":20,"Double":3.14,"Boolean":true}

PostRequest.Method = httpGET
Debug.Print PostRequest.FormattedResource
' -> ?Integer=20&Double=3.14&Boolean=True

To update your spreadsheet, remove the existing RestRequest class and add the updated version (1.0.2). Seems to be working better now, but let me know if you have any other issues.

@RibeyeOnTheBone
Copy link
Author

Tim,

Not only helpful software but helpful support as well! If you are ever in London I owe you a pint.

I will test that now and revert is there are any problems.

Greg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants