Android App RestApi Post

Hi, how can send command via post like
curl -X POST --header “Content-Type: text/plain” --header “Accept: application/json” -d “OFF” “http://ip_openHAB_host:8080/rest/items/My_Item”

i tryed different way but never do the better result its
[WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/Presence_Mobile_John’ with an invalid status value ‘’.

im tryng whit

I don’t know much about Android developement, but it seems the value, you’re trying to POST doesn’t fit with the item definition.
e.g. you’re sending an STRING and the item expects an Number.

no the problem is how to generate the post request in “android java” passing this header
–header “Content-Type: text/plain” --header “Accept: application/json”
and this value
-d “OFF” and what do u mead -d
nobody know or do something like that

ok, that’s not my cup of tea! :wink:
but what I can say, if the itemtypes won’t match, you’ll see that entry in the logs.

[WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/Presence_Mobile_John’ with an invalid status value ‘’.

But from what I’m reading, I guess, you’re trying to update a presence-item? there are a few threads here on how to do that, ranging from

Thnks for the fast reply binderthThomas Binder but the link suggest dont help me.

I do this request, with succes, changing the item switch state in jscript in this easy way

fetch(‘’, {
method: ‘POST’,
‘Content-Type’: ‘text/plain’,
Accept : ‘application/json’,
body: ‘ON’


and i want replay this in android native app whit java

I’m no developer at all, but I think you missed something important!
try this:

fetch('', {
method: 'POST',
Content-Type: 'text/plain',
Accept: 'application/json',
body: 'ON'

What did I change:

  • added /state to your URL
  • removed the ' from Content-Type (I don’t think, that’s needed?)
  • changed the to ' (but I think, that’s the browser’s fault)

sorry man, but my example works fine.
I just want say, that i need reply the same post request in java, for android native app.

whatch in this page there is many example but not java lmao

ok. I told you, I’m not a developer! :joy:
But I’m sure, there are enough JAVA-keen here, who can help you out.

Have you found a solution to your issue? I’m currently working on a native android app and struggling with the same problem.

Get commands working fine but i don’t know how to send a Post command because of the -d “ON” field.