Orion ContextBroker: Notify to Custom WebService - fiware

I'm trying to integrate Orion notification with a custom WebService, but I'm not able to get data in the WebService.
I have the subscription defined like I subscribed Cygnus, but with WebService url.
Orion's output:
DEBUG#10:34:04 httpRequestSend.cpp[299]: HTTP-HEADERS: 'User-Agent: orion/0.23.0 libcurl/7.19.7'
DEBUG#10:34:04 httpRequestSend.cpp[307]: HTTP-HEADERS: 'Host: xxxxxxxxxxxxx.es:8080'
DEBUG#10:34:04 httpRequestSend.cpp[351]: HTTP-HEADERS: 'Content-length: 3277'
DEBUG#10:34:04 httpRequestSend.cpp[419]: Sending message 174 to HTTP server: sending message of 3518 bytes to HTTP server
INFO#10:34:04 httpRequestSend.cpp[434]: Notification Successfully Sent to xxxxxxxxxxxxx:8080/PruebasREST/webresources/service
INFO#10:34:04 httpRequestSend.cpp[445]: Transaction ended
If I do a json POST curl in a console, the WebService is working as expected, but when Orion sends notification there is no response from the WebService.
Does anyone imagine what is happening?
Thanks

I don't know what you are expecting to receive from your server, but I can tell you that Orion is not expecting anything.
When doing notifications it will send them out and not really care whether there is an HTTP response from the other end.

SOLVED
The problem was the Accept Header sent by Orion.
The WebService response wasn't the same type than the Accept Header
Thanks to LeandroGuillen for giving me the clue to know the exact format of Orion's json POST with accumulator-service.py

Related

Camunda:Http Connector Post Method With Content-Type application/json

I want to use data i have parsed form precious service and make post request for writing this data in another databasei in postman my post request looks like this :
and here is my http connector post request exmple:
The parameter is called payload and not body.
See camunda documentation about connector.

AWS IoT JSON Error

I'm trying to get a Skywire LTE Cat 1 modem (http://nimbelink.com/skywire-4g-lte-cat-1/) to update a thing shadow on AWS IoT. I have the device talking to AWS via HTTP, and am able to execute a GET command per their tutorial.
Now I am trying to execute a POST command to update my thing's shadow. However, whenever I try to send my POST command:
POST /things/AWS_Test_Thing/shadow HTTP/1.1
BODY: {"state":{"reported":{"Temp":55}}}
AWS sends me the following error:
HTTP/1.1 Bad Request
{"message":"Payload contains invalid json","traceId":"e53be1d6-7967f52c-4dd6-d7b95cc20628"}
I've never used JSON before, but from what I can gather,
{"state":{"reported":{"Temp":55}}}
should be valid JSON and complies with AWS IoT documentation (http://docs.aws.amazon.com/iot/latest/developerguide/thing-shadow-document-syntax.html#thing-shadow-example-request-json). What am I missing?
If you are updating the shadow via a POST request, you should have a "desired" statement instead of "reported".
Make sure you have the Content-Length header included as part of the request and signing procedure. The Content-Length must reflect the size of the JSON payload you are sending.

Post request and get response robotframework

I need to send POST request and get json from it.
Create Http Context emopstest.pdc.org http
Set Request Header Content-Type application/x-www-form-urlencoded
Set Request Header Authorization Basic bG9naW46cGFzcw==
${dict}= Create Dictionary app_ids=18 where=ROWNUM<=2000
${value}= Stringify Json ${dict}
Set Request Body ${value}
HttpLibrary.HTTP.POST /auth_srv/services/auth/1/json/get_hazards
Show Response Body In Browser
Response Status Code Should Equal 200
${result_text}= Get Response Body
${result_json}= Parse Json ${result_text}
But this code returns to me 404...
What is wrong?
The 404 means that the server couldn't find the resource you requested. Usually that means the URL was wrong. Depending on how the server is configured, it could also mean that your authorization is wrong (ie: some applications will give a 404 in the case of bad authentication, so that an attacker isn't given a clue that the credentials are incorrect)
The server logs should have information that will help you track down whether you have an incorrect URL or that the server has a bug.

REST API, OAuth2 and authentification errors

First, thanks you for your replies.
I try to make an REST API with nodeJS, and i think, oAuth2 is the best way to authenticates users against my system.
Users are stored in LDAP, and api keys will be keep on MySQL engine. Client account code will be also store in MySQL.
All process is OK, users are authenticated, API token has been saved in MySQL but when i try to use this token, passport refuse to authenticated my request and return :
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (http.js:691:11)
at ServerResponse.res.setHeader (/home/lolostates/Developpement/nodejs/oauth2/test/node_modules/express/node_modules/connect/lib/patch.js:62:20)
at ServerResponse.res.header (/home/lolostates/Developpement/nodejs/oauth2/test/node_modules/express/lib/response.js:280:8)
at ServerResponse.res.json (/home/lolostates/Developpement/nodejs/oauth2/test/node_modules/express/lib/response.js:135:8)
at exports.info (/home/lolostates/Developpement/nodejs/oauth2/test/user.js:13:9)
at callbacks (/home/lolostates/Developpement/nodejs/oauth2/test/node_modules/express/lib/router/index.js:272:11)
at complete (/home/lolostates/Developpement/nodejs/oauth2/test/node_modules/passport/lib/passport/middleware/authenticate.js:218:13)
at /home/lolostates/Developpement/nodejs/oauth2/test/node_modules/passport/lib/passport/middleware/authenticate.js:200:15
at pass (/home/lolostates/Developpement/nodejs/oauth2/test/node_modules/passport/lib/passport/index.js:399:14)
at Passport.transformAuthInfo (/home/lolostates/Developpement/nodejs/oauth2/test/node_modules/passport/lib/passport/index.js:415:5)
Request are send by curl:
curl -H "Authorization: Bearer NoulKM889Aksf60rQONcUJwMuZHI3PDqzeXfkX3Li2BohsxNVsOrd2LLdvJAGZuE168IukUCPbviazhvBjt7VDfLFUMJRIY1fa95kGXQQKzE7etFhocsnYvbLSixbHRmCwXNx5FKj6v83Ci9f9xLqRinEKwaAUIjs03hhq8dCWIp7S0Cbi5jdkxlzwfpZxuShoAZYaFInlf4ymG5oyzQe0WJ2POXOaMarGLO7NkjyIMJXWh7s0Y" http://localhost:3000/api/userinfo
I use passport-http-bearer, oAuth2orize, and all example functions presented in OAuth2orize examples.
Could you please explain me why ?
It appears that you attempted to set a response header after the response was sent back. Check to make sure you didn't call res.end() (or a similar method) before you tried to set the headers.

Creating requests in fiddler2 gives a 401 unauthorized but the 200 negotiated request doesn't follow

I'm trying to use fiddler to generate requests to receive a JSON response. I drag a request that was captured from IE with a 200 response into the request builder then change the Accept header to "Accept: application/json".
After that I execute the request and get a 401 unauthorized response but the negotiation with a following 200 response does not take place. If there another way I can get this to work?
The reason I was heading down this path was to track down why my AJAX requests against the SharePoint 2010 WCF data services were not returning data while using the .getJSON method in jQuery. Turns out the SP2010 WCF data services escape single quotes in the JSON response.
Single quotes should not be escaped according to the JSON spec.