Not able to send data to Ignite cache through HTTP POST - xmlhttprequest

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.

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")

Related

UPDATE and REVISE rest api is not working in vTiger CRM cloud service

So basically I need to use the update/revise Rest API to update the fields in the vTiger CRM.
But when I am using the rest API (link : https://help.vtiger.com/article/147111249-Rest-API-Manual) to update the fields, I am getting the error as "400 Unsupported operations: The request cannot be fulfilled due to bad syntax."
My api : endpoint/reviseelement=convert_into_json_string({id:5x369, potentialname:'demo2'})
Also apart from this, I had used the SQL query Rest API, to update the record in the modules, but it is also giving me the same error as: "400 Unsupported operations: The request cannot be fulfilled due to bad syntax."
My Api query : endpoint/query?query=UPDATE Potentials SET potentialname = 'demo2 where id = 5x369;
Also by using the webservice(https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html) rest api I am getting error like : "Permission to perform the operations is denied for id: ".
So how can I use the update api. Can anyone please help?
For web services API (https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html),
When you pass the payload data, make sure you're passing the x-www-form-urlencoded form of data.
Also, make sure you're passing 'element' argument with value like this:
{"id": "10x11471458", "leadsource": "Facebook"}.
if you're still facing this issue, you can share more details and I'll be happy to help you.
If you still need to do this the following should work.
Method: POST
End Point: /revise
Headers: "Authorization: Basic YOUR_TOKEN"
Body:
{
"element": {
"id":"5x369",
"potentialname": "demo2"
}
}
reference: https://www.vtiger.com/docs/rest-api-for-vtiger#/Revise

Webclient with spring boot : Random occurrences of 400 bad request with the same type input data set

I have list of input data ex(ids = 1,2,3,4,5,6...)I am trying to access those(urls like : https://localhost:8080/1) using webclient then it is giving 400 bad request for random ids like
In https://localhost:8080/1 sometimes I am getting bad request and proper response for the same as well as some times I am getting bad request https://localhost:8080/2 and getting proper response for the same. I am not understanding where it is going wrong. Can anyone help me with this, Thanks in advance

In karate mocking (karate-netty), how can we override request header value?

Objective:
We want few API calls should go to mock-server(https://192.x.x.x:8001) and others should go to an actual downstream application server(https://dev.api.acme.com).
Setup :
On local, mock server is up with standalone jar on port 8001. e.g https://192.x.x.x:8001
In application config file (config.property)downstream system(which need to mock) defined with mockserver IP i.e https://192.x.x.x:8001
Testing scenario and problem:
1.
Scenario: pathMatches('/profile/v1/users/{id}/user')
* karate.proceed('https://dev.api.acme.com')
* def response = read ('findScope.json')
* def responseStatus = 200ˀˀ
* print 'created response is: ' + response
Now, when we hit API request via postman or feature file then it does karate.proceed properly to https://dev.api.acme.com/profile/v1/users/123/user instead of 192.x.x.x. However, in this request, host is referring to https://192.x.x.x:8001 instead of https://dev.api.acme.com which create a problem for us.
How can we override request header in this case? I did try with karate.set and also with header host=https://192.x.x.x:8001 but no luck.
Thanks!
Please see if the 1.0 version works: https://github.com/intuit/karate/wiki/1.0-upgrade-guide
Unfortunately https proxying may not work as mentioned. If you are depending on this, we may need your help (code contribution) to get this working
If the Host header is still not mutable, that also can be considered a feature request, and here also I'd request you to consider contributing code

Azure Stream Analytics: REST Api for creating new ASA job giving MissingApiVersionParameter error

I want to create new ASA job using rest end point with input output and query for job.
I've followed this link
https://learn.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-job
and formed below url according to above link
https://management.azure.com/subscriptions/{subscription-id}/
resourcegroups/{resourcegroup-name}/providers/Microsoft.StreamAnalytics/
streamingjobs/dynamicStream?api-version=2015-10-01
Though I've provided api version query parameter, postman is giving me below error
{
"error": {
"code": "MissingApiVersionParameter",
"message": "The api-version query parameter (?api-version=) is required for all requests."
}
}
Any idea what am I doing wrong ?
Api for creating new input for stream analytics job is behaving in same way
Thank you for reading !!!
POSTMAN issue !
Tried using different method and it's working .

Response from Turn Server in REST API mode

I have established rfc5766-turnserver and tested success in web browser. IP:192.168.1.111, port:3478. Now I want to get JSON response from server.
in here says the request format should be like
GET /?service=turn&username=mbzrxpgjys
and response should be JSON like
{
"username" : "12334939:mbzrxpgjys",
"password" : "adfsaflsjfldssia",
"ttl" : 86400,
"uris" : [
"turn:1.2.3.4:9991?transport=udp",
"turn:1.2.3.4:9992?transport=tcp",
"turns:1.2.3.4:443?transport=tcp"
]
}
in WebRTC demo Apprtc, file constans.py make the configuration:
TURN_BASE_URL="http://192.168.1.111"
TURN_URL_TEMPLATE="%s/turn.php?username=%s&key=%s"
CEOD_KEY="4080218913"
when the application send a request:"http://192.168.1.111/turn.php?username=xxx&key=4080218913"
nothing returned but a 404 error. if I changed the request as "http://192.168.1.111:3478/turn.php?username=xxx&key=4080218913" I get a html response not a JSON. So I want to know where is the problem? the configuration error or request format?
Sorry for such naive question but it does confused me many days.
Thanks