Openedge.Net.URI AddQuery and duplicate query names with dif

Posted by mroberts@rev.com.au on 15-Aug-2017 00:04

Hi,

I'm making a call to a REST API of a system monitoring server.

I'm querying event data over the last month to determine server uptime.

There are event types of 0,1,2,3 ... and to show all, the query should have

server/.../event

When using URI, I try

oURI = Openedge.Net.URI:Parse(ipcURL).
oURI:Path = ipcPath.
oURI:AddQuery("eventtype","0").
oURI:AddQuery("eventtype","1").
oURI:AddQuery("eventtype","2").
oURI:AddQuery("eventtype","3").

The resulting URL only has the ?eventtype=3 , as the AddQuery does not seem to handle duplicates, and the last one added trumps the rest.

Is there a recommended method to use the URI object to add duplicate query names, to allow multiples to appear.

Thanks

Mark

Posted by Peter Judge on 15-Aug-2017 08:41

The URI stores query string keyed off the name (hence no dups). The URI (and the rest of the HTTP client) aims to be HTTP spec-compliant. However, the URI spec ([View:https://tools.ietf.org/html/rfc3986#page-23:550:50])  does not define the behaviour of the query string and so we had to choose an approach, and decided on unique query string names.

A similar discussion is at [View:https://stackoverflow.com/questions/1746507/authoritative-position-of-duplicate-http-get-query-keys#1746566:550:50]

If you have control over the server/URI then you could do something like

server/.../event

or you could send a single query parameter with complex data

server/.../event ]

or similar.

All Replies

Posted by mroberts@rev.com.au on 15-Aug-2017 00:52

Just realised I missed the obvious,  I'm running OE11.7.1.

Posted by Peter Judge on 15-Aug-2017 08:41

The URI stores query string keyed off the name (hence no dups). The URI (and the rest of the HTTP client) aims to be HTTP spec-compliant. However, the URI spec ([View:https://tools.ietf.org/html/rfc3986#page-23:550:50])  does not define the behaviour of the query string and so we had to choose an approach, and decided on unique query string names.

A similar discussion is at [View:https://stackoverflow.com/questions/1746507/authoritative-position-of-duplicate-http-get-query-keys#1746566:550:50]

If you have control over the server/URI then you could do something like

server/.../event

or you could send a single query parameter with complex data

server/.../event ]

or similar.

Posted by mroberts@rev.com.au on 16-Aug-2017 00:21

Thanks Peter

I have no control over the server side, so I will redo my code to not use the URI ... it's a pain, as the URI was working fine for the other 99% of what I am doing :)

Mark

Posted by onnodehaan on 16-Aug-2017 04:07

Hi Mark,

As an alternative, you could write your own HTTP class, using sockets. It's not that hard. And it gives you maximum flexibility.

Posted by Peter Judge on 16-Aug-2017 08:28

Just an FYI – the OpenEdge.Net.* classes are ABL-socket-based. “Net” == “network” and not the Microsoft product.
 
 
 

This thread is closed