Search code examples
xmlhttprequesthttp-posthttp-getscala.jsignite

Not able to send data to Ignite cache through HTTP POST


I am trying to put data into Apache Ignite cache using their REST API. So, I used the following links : To put data into cache :

http://localhost:8080/ignite?cmd=put&key=1&val=b&destId=09f7232d

Now, to get this data from cache I used :

http://localhost:8080/ignite?cmd=get&key=1&destId=09f7232d

for this, I am getting positive response :

{"successStatus":0,"affinityNodeId":"09f7232d-fb4b-4080-b45d-ddd18ce2e32e","sessionToken":"","error":"","response":"b"}

But when I tried to send data to Ignite using HTTP POST using XmlHttpRequest through my scalajs application, it is showing "400 Bad Request"

My code for POST is :

val xp = new dom.XMLHttpRequest()
val purl="http://localhost:8080/ignite" 
xp.open("POST",purl )
xp.send("cmd=put&key=1&val=a&destId=09f7232d")

Can someone please explain why it is showing such behavior ? Thanks in advance.


Solution

  • I solved my problem using below code :

    val xp = new dom.XMLHttpRequest()
    val purl="http://localhost:8080/ignite?cmd=put&key=1&val=a&destId=09f7232d" 
    xp.open("POST",purl )
    xp.send("grant_type=client_credentials")