sendHttpGetRequest: Error in Documentation?

Hi all,

I’m trying to get rid of HTTP Binding by implementing a DSL Rule which periodically sends a GET-Request.
Since the request needs some headers to get the data in json I’m trying to use sendHttpGetRequest(String url, Map<String, String> headers, int timeout) as described in https://www.openhab.org/docs/configuration/actions.html#http-actions.

Unfortunately this gives me the following error:

2020-03-06 09:47:00.536 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Get next recordings': Could not invoke method: org.eclipse.smarthome.model.script.actions.HTTP.sendHttpGetRequest(java.lang.String,int) on instance: null

I checked a bit into source code and I can’t find a method that includes headers in https://github.com/eclipse/smarthome/blob/master/bundles/model/org.eclipse.smarthome.model.script/src/org/eclipse/smarthome/model/script/actions/HTTP.java

Before digging deeper I’d like to ask if somebody is using HTTP action in this way or if there might be an error in the documentation?

Regards,
Christian

It looks like the ability to include headers was added to the core on December 19, which is after the 2.5.0 release was made. This means the feature will be in 3.0, which won’t be out until later this year.

If you look at the 2.5 version of the docs, you won’t find that API. Note that you can select the doc version in the upper right corner of each page of the documentation.

I suppose one could argue that the default version of the doc should be “2.5”, not “latest”.

1 Like

Thanks. Didn’t recognize that I’m looking at the wrong version of the docs.

Seems I need to find a different approach to solve my issue then. :frowning:

I think others have solved this by calling a bash script that uses curl to do what you want.

@Kai @ysc @Confectrician Shouldn’t the default version of the documentation be “2.5” instead of “latest”? I don’t think too many people will notice the drop down at the top of the page. As a result they will be confused when they see features that are in the docs but don’t work.

Apologize in advance if this is already on someone’s radar screen.

Saw some posts when searching for this issue. Will research and see what I can do.

I have also a different solution in mind that publishes the data via mqtt on server side what will avoid polling.

The latest docs should be related to the 2.5 version.

Maybe this was introduced before we implemented the mechanism for that.

OH3 docs are currently on a separate domain to just prevent something like this.

Very good chance of that. The above-mentioned feature was merged a couple days after the 2.5 release was cut.

Then it’s still confusing because the Version drop down contains options for “latest” and “2.5”. If “latest” is 2.5, then what is “2.5”

The Version drop down contains “latest” and “2.5”.

list

you are right this could be confusing.
Maybe we should rename that temporary.

Latest is 2.5.x which includes the patch release contents.

Ah, I see now. I was just thinking openhab-core, which is stuck at 2.5. So the 2.5 tag means the 2.5 release?

And now I understand why “latest” is there - to account for all the 2.5.x bindings, which will continue to change as PRs are merged.

Maybe it was the fact that the sendHttpGetRequest “latest” doc included a 3.0 change. But that was just a timing issue with the change to core versus the introduction of the versioning mechanism.

1 Like

Yes I have branched out the 3.x docs on Feb 10th, before that it’s possible that changes meant for 3.x ended up in what is now the 2.5.x docs; FTR, there should no mentions of openHAB 3 on https://www.openhab.org/docs for now, the site for the upcoming OH3 is now sitting at https://next.openhab.org and is completely separate, so we’re completely free to do a - much needed IMO - overhaul of the docs without worry.

When openHAB 3 and its docs are in good shape, of course, there will be a link or banner to get to the “next” website for interested visitors until it eventually replaces the production one.

In short if you want to contribute to the docs for 2.x open PRs for the 2.5.x branch (the default) and if you want to contribute to the docs for 3.x open them for the master branch. Details here: https://github.com/openhab/openhab-docs/issues/1133#issuecomment-584287289

1 Like

Digging up old topic here - the “new”/archived v2 docs still include reference to headers with HTTP Actions.

So far as I can make out, simply not available in OH2.5?

Would I be correct to edit this out?

Yes that would be correct.

But be aware that the “edit this page” link seems to have a bug due to our latest changes, which i have recognized just while looking at this post and page.
Please make sure to give your pull request a proper “2.5.x” title, so we can sort that out and get the changes into the right place.

I will add an issue for the wrong edit links and will try to fix them asap.

1 Like

Okeydoke, I think I’ll have to wait for the link fix, attempting it now leads to 3.x docs page