Orion CB: Can't Access Entities via /v2/entities endpoint - fiware

While creating a wirecloud wiring using NGSI Source operator, I encountered an error (helpless error) for couple of days, regarding connection to my instance of Orion CB. I can confirm all other NGSI operator settings entered are correct.
Error creating subscription in the context broker server: Connection Error
I however, suspect this error has to do with Orion NOT finding the entities to subscribe the NGSI Source operator. This is because I tried accessing Eindhoven's broker (http://212.159.228.70:1026/) and it works, NGSI Source operator subscription created successfully.
Equally, I get all entities/attributes in the Eindhoven's broker using:
Akil$http http://212.159.228.70:1026/v2/entities
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 15501
Content-Type: application/json
Date: Mon, 13 May 2019 10:20:20 GMT
Fiware-Correlator: b5e5294a-7568-11e9-83c8-0242ac120003
[
{
"NO2": {
"metadata": {},
"type": "Number",
"value": 27.5
},
"Ozon": {
"metadata": {},
"type": "Number",
"value": 59.5
},
"PM1": {
"metadata": {},
"type": "Number",
"value": 8
},
"PM10": {
"metadata": {},
"type": "Number",
"value": 12
},
.
.
}
]
But then I cannot get the entities in my Orion instance using same scenario:
Akil$ http 193.136.xx.xx:53154/v2/entities
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 2
Content-Type: application/json
Date: Mon, 13 May 2019 10:36:13 GMT
Fiware-Correlator: ee22e4b2-756a-11e9-afa1-0242ac160007
[]
Return empty list, whereas I have available 2 FIWARE services: environment and urbansense. The entities I want to access are available with the urbansense fiware-service having /basic fiware-servicepath.
Service health:
Akil$ http 193.136.xx.xx:53154/version
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 345
Content-Type: application/json
Date: Mon, 13 May 2019 10:50:13 GMT
Fiware-Correlator: e32bf3da-756c-11e9-9371-0242ac160007
{
"orion": {
"compile_time": "Tue Feb 12 10:51:10 UTC 2019",
"compiled_by": "root",
"compiled_in": "4f8128ac7b5b",
"doc": "https://fiware-orion.rtfd.io/",
"git_hash": "7ae8c69b97cd875236b952322a6bd503debbd13d",
"release_date": "Tue Feb 12 10:51:10 UTC 2019",
"uptime": "6 d, 18 h, 7 m, 6 s",
"version": "2.1.0-next"
}
}
Questions:
Why can't I access my Orion instance same way I accessed Eindhoven's
broker?
Is this the reason why my wiring for NGSI Source operator
failed, thus reporting subscription error above?

I'm not sure of fully understading your case (specially the relationship with Wirecloud, as I'm not an expert in Wirecloud), but let's try to answer... :)
From:
[GET /v2/entities] Return empty list, whereas I have available 2 FIWARE services: environment and urbansense. The entities I want to access are available with the urbansense fiware-service having /basic fiware-servicepath.
If the entities you want to access are available in a given service and subservice, then you should add then to the GET request. I don't know how the http command works, but if it were curl it would be something like this
curl -H 'fiware-service: environment' and -H 'fiware-servicepath: /basic' http://212.159.228.70:1026/v2/entities

Related

Jira curl issue create ends with error HTTP 415

I am trying to create issue in project via curl, but it ends with 415 error which I don't know why as I am pasting only text there.
curl -D- -s -u email:api_key -X POST --data "{\"fields\":{\"project\":{\"key\": \"PROBLEM\"},\"summary\": \"REST ye merry gentlemen.\",\"description\": \"Creating of an issue using project keys and issue type names using the REST API\",\"issuetype\": {\"name\": \"Outage\"}}}" https://company.atlassian.net/rest/api/2/issue/
Output:
HTTP/2 415
date: Tue, 27 Sep 2022 11:14:10 GMT
content-type: text/html;charset=UTF-8
server: globaledge-envoy
timing-allow-origin: *
x-arequestid: bbc0506d-8e7c-442f-a180-46632081b6a5
set-cookie: atlassian.xsrf.token=BAHL-ME69-JQ45-BS4O_929b97ddce3a4de2b40abbd3d2817ff133d29cee_lin; path=/; SameSite=None; Secure
x-aaccountid: 62b303db84d73c7201680c55
x-envoy-upstream-service-time: 56
expect-ct: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/atlassian-proxy", max-age=86400
strict-transport-security: max-age=63072000; preload
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
atl-traceid: b0b3324454c29763
report-to: {"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}
nel: {"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}
vary: Accept-Encoding
I don't understand why I am getting 415 message from Jira.
HTTP 415 means Unsupported Media Type (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415).
Basically, you have to tell JIRA you are sending a JSON. Just add:
-H 'Content-Type: application/json'
to your curl command.
Also another note you may want to use
rest/api/3/issue/ instead of rest/api/2/issue/
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-createmeta-get
and if you got some error message like:
Operation value must be an Atlassian Document (see the Atlassian Document Format)
change your "description" field to something like this:
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Creating of an issue using project keys and issue type names using the REST API"
}
]
}
]
}
For example
curl -i -u nanana#gmail.com:xxxxxx -H 'Content-Type: application/json' -XPOST --data '{"fields": {"project": {"key": "RW"}, "summary": "REST ye merry gentlemen.", "description": {"type": "doc", "version": 1, "content": [{"type": "paragraph", "content": [{"type": "text", "text": "Creating of an issue using project keys and issue type names using the REST API"} ] } ] }, "issuetype": {"name": "Task"} } }' https://s50600822.atlassian.net/rest/api/3/issue
{"id":"10013","key":"RW-6","self":"https://s50600822.atlassian.net/rest/api/3/issue/10013"}

Account linking error: "Can't parse the response. The response needs to be JSON format."

I am attempting account linking within 'Actions on Google'. Everything works until my OAuth provider responds to Google's request for tokens.
This is the JSON that is returned and appears to be properly formatted:
{"access_token":"edeaa27e-12b7-43a1-bc7c-e6bbf9af71c3","expires_in":5184000.0,"refresh_token":"4344383b-cf07-4d12-a5c2-44b6481f5f48","token_type":"Bearer"}
This is the error:
{ "#type": "type.googleapis.com/google.identity.accountlinking.type.AccountLinkingError", "errorReason": "Can't parse the response. The response needs to be JSON format.", "response": { ... }, "step": "AUTH_CODE_EXCHANGE" }
Details:
{
"insertId": "-hgv4mfb4b",
"jsonPayload": {
"#type": "type.googleapis.com/google.identity.accountlinking.type.AccountLinkingError",
"errorReason": "Can't parse the response. The response needs to be JSON format.",
"response": {
"status": 200,
"body": "{\"access_token\":\"cdd79134-316d-46ca-8d82-62fc7c35d905\",\"expires_in\":5184000.0,\"refresh_token\":\"fc63ceb3-0a8d-40ac-a1a3-a8cfab110bef\",\"token_type\":\"Bearer\"}"
},
"step": "AUTH_CODE_EXCHANGE"
},
"resource": {
"type": "assistant_action_project",
"labels": {
"project_id": "my-project"
}
},
"timestamp": "2021-07-30T23:15:28.221Z",
"severity": "ERROR",
"logName": "projects/my-project/logs/accountlinking-pa.googleapis.com%2Ferror",
"receiveTimestamp": "2021-07-30T23:15:28.676796217Z"
}
Here is the response from my OAuth provider via curl. This is what Google gets. It looks like properly formatted JSON.
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Cache-Control: private
Cache-Control: private
< Content-Type: application/json; charset=utf-8
Content-Type: application/json; charset=utf-8
< Vary: Accept
Vary: Accept
< Server: Microsoft-IIS/8.5
Server: Microsoft-IIS/8.5
< Request-Context: appId=cid-v1:f494398c-ac65-47c8-84be-65aea2c190a4
Request-Context: appId=cid-v1:f494398c-ac65-47c8-84be-65aea2c190a4
< X-HOST-nonce: 3eTaf/2/7riVVh24uAsUT+KHqcJPq0F2cw7C5ldMkMF4iH5rDbHQEgOp2OU9RaQFr/HjBBEpkKekcCxlmzek5g==
X-HOST-nonce: 3eTaf/2/7riVVh24uAsUT+KHqcJPq0F2cw7C5ldMkMF4iH5rDbHQEgOp2OU9RaQFr/HjBBEpkKekcCxlmzek5g==
< X-Powered-By: ServiceStack/4.040 Win32NT/.NET
X-Powered-By: ServiceStack/4.040 Win32NT/.NET
< X-AspNet-Version: 4.0.30319
X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
< Date: Tue, 03 Aug 2021 03:17:00 GMT
Date: Tue, 03 Aug 2021 03:17:00 GMT
< Content-Length: 155
Content-Length: 155
< x-HOST-proxy: true
x-HOST-proxy: true
< Strict-Transport-Security: max-age=15768000
Strict-Transport-Security: max-age=15768000
{"access_token":"6cff16ee-3b3e-4ecf-9664-51515ede6cc8","expires_in":5184000.0,"refresh_token":"03725df6-8d4c-434a-ab36-adedb43b76d7","token_type":"Bearer"}
Google will not accept the 'expires_in' value above, because it includes a decimal. Not sure if this impacts all values with a decimal or just '.0', but the OAuth spec doesn't seem to specifically exclude such a value. Javascript converts any float with just a 0 after the decimal to a whole number. My issue was that the 3rd party OAuth provider was returning a string including a float that Google would not parse as JSON.

No enterprise was found for the given id

I have a valid Organization created at https://play.google.com/work. When I use the Organization ID available here as Enterprise Id for API calls avaialbe at https://developers.google.com/apis-explorer/#p/androidenterprise/v1/ , I am always getting below response.
404
cache-control: private, max-age=0 content-encoding: gzip content-length: 175 content-type: application/json; charset=UTF-8 date: Mon, 17 Jun 2019 07:47:15 GMT expires: Mon, 17 Jun 2019 07:47:15 GMT server: GSE vary: Origin, X-Origin
{ "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "No enterprise was found for the given id.", "locationType": "parameter", "location": "enterpriseId" } ], "code": 404, "message": "No enterprise was found for the given id." } }
Note: OAuth 2.0 Authorization is on.
This error could arise when the enterprise has already been deleted from Google console (https://play.google.com/work). You can navigate to above URL and in admin settings you can view your enterprise.

Handling Malformed JSON generated by the Microsoft Academic Knowledge API

Making the following request to the Microsoft Academic gives malformed JSON:
https://westus.api.cognitive.microsoft.com/academic/v1.0/interpret?
query=albert einstein&complete=0&count=2&offset=2&model=latest
The result is as follows
Request-Context: appId=cid-v1:7cd06f0e-6d73-46a5-9c10-4ebe681d0156
apim-request-id: 8eec6818-55d3-4b7c-b1c3-b4c6236f0173
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
Date: Tue, 31 Oct 2017 01:02:11 GMT
X-Powered-By: ASP.NET
Content-Length: 681
Content-Type: application/json
{
"query": "albert einstein",
"interpretations": [,
{
"logprob": -69.749,
"parse": "<rule name=\"#GetPapers\"><attr name=\"academic#W\">albert</attr> <attr name=\"academic#F.FN\">einstein</attr></rule>",
"rules": [{
"name": "#GetPapers",
"output": {
"type": "query",
"value": "And(W='albert',Composite(F.FN=='einstein'))"
}
}]
},
{
"logprob": -118.575,
"parse": "<rule name=\"#GetPapers\"><attr name=\"academic#W\">albert</attr> <attr name=\"academic#W\">einstein</attr></rule>",
"rules": [{
"name": "#GetPapers",
"output": {
"type": "query",
"value": "And(W='albert',W='einstein')"
}
}]
}
]
}
Notice the leading comma on the third line of the JSON, at the beginning of the interpretations array. I suspect there's a bug in the code used to paginate results. I'm working in Python, and that leading comma breaks every parser I can think of including a straight eval. I think I can handle it with a String.replace before using json.loads, but that's an ugly solution. Are there better alternatives? And am I correct to think this is a bug?

WebApi with Odata NextPage and Count not appearing in the JSON response

I have a webapi method that I want to switch oData paging etc on.
I followed the example in http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/supporting-odata-query-options
My method looks like:
public PageResult<UserViewModel> GetUsers(ODataQueryOptions<UserViewModel> options)
{
var settings = new ODataQuerySettings()
{
PageSize = 2
};
var results = UserLogic.GetUsers(userId, UserManager, _db);
var filtered = options.ApplyTo(results, settings);
var pagedResult = new PageResult<UserViewModel>(
filtered as IEnumerable<UserViewModel>,
Request.GetNextPageLink(),
Request.GetInlineCount());
return pagedResult;
}
That the count is populated and the next page link is there and the correct oData options are applied i.e. sort order etc. When I return it in my api method, the correct data comes back, but the count and next link don't appear in my json.
Am I missing a setting to turn this on?
i.e. this is my json response:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-RequestID: b215962b-6a4a-431d-9850-7ecbf808538e
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcUmVwb3NpdG9yaWVzXEdpdEh1YlxxbGRyYS1wb3J0YWxccWxkcmEtcG9ydGFsLldlYlxxbGRyYS5iYXNlbGluZS5hcGlcYXBpXHVzZXJz?=
X-Powered-By: ASP.NET
Date: Fri, 04 Apr 2014 05:16:53 GMT
Content-Length: 554
[
{
"Id": "500e6f96-b2bd-48d9-8181-5bbc39c673f6",
"UserName": "adam#test.com",
"Organisation": {
"Id": "f179bc35-89b8-e311-9dfd-0050569b4cee",
"Name": "Black and White Cabs Pty Ltd",
"IsActive": true,
"LastUpdatedDate": "2014-04-03T11:35:26.167"
},
"IsLockedOut": false,
"Roles": []
},
{
"Id": "0d661d1b-9e52-4f2f-baec-3eb89197bb6d",
"UserName": "bob#test.com",
"Organisation": null,
"IsLockedOut": false,
"Roles": [
"Service Administrator"
]
}
]
This should work.
Be sure to remove the [EnableQuery] attribute if it is being applied to your method or controller. This will cause the returned JSON to not include the count and next link.