ejabberd set_preference rest api is throwing error - ejabberd

Can anyone please help with rest api of ejabberd's set preference
following is the request body
{
"user": "venkat",
"host": "localhost",
"resource": "tka1",
"type": "available",
"show": "away",
"status": "",
"priority": "0"
}
when I am trying to hit api i am getting response as "internal_error".
IN logs, I could see below statement
REST API Error:
set_presence([{<<"user">>,<<"venkat">>},
{<<"host">>,<<"localhost">>},
{<<"resource">>,<<"tka1">>},
{<<"type">>,<<"available">>},
{<<"show">>,<<"away">>},
{<<"status">>,<<>>},{<<"priority">>,<<"0">>}])
-> exit:{noproc,{p1_server,call,[none,
{set_presence,{presence,<<>>,available,<<>>,
{jid,<<"venkat">>,<<"localhost">>,<<"tka1">>,<<"venkat">>,<<"localhost">>,<<"tka1">>},
{jid,<<"venkat">>,<<"localhost">>,<<>>,<<"venkat">>,<<"localhost">>,<<>>},away,[],0,[],#{}}},1000]}}
[{p1_server,call,3,[{file,"src/p1_server.erl"},{line,210}]},{mod_http_api,handle2,4,[{file,"src/mod_http_api.erl"},{line,268}]},{mod_http_api,handle,4,[{file,"src/mod_http_api.erl"},{line,229}]},{mod_http_api,perform_call,4,[{file,"src/mod_http_api.erl"},{line,189}]},{mod_http_api,process,2,[{file,"src/mod_http_api.erl"},{line,142}]},{ejabberd_http,process,2,[{file,"src/ejabberd_http.erl"},{line,373}]},{ejabberd_http,process_request,1,[{file,"src/ejabberd_http.erl"},{line,496}]},{ejabberd_http,process_header,2,[{file,"src/ejabberd_http.erl"},{line,293}]}]
Using ejabberd 20.07 version

That API is used to set presence of an existing XMPP session.
In your experiment, is the account venkat#localhost logged in the server with resource "tka1"?

Related

NotAuthorizedOrNotFound when pushing custom metric

When I try to push a custom metric to the Oracle Cloud Monitoring service using the Oracle Cloud CLI, I receive the following error:
ServiceError:
{
"code": "NotAuthorizedOrNotFound",
"message": "Authorization failed or requested resource not found.",
"opc-request-id": "request id",
"status": 404
}
This occurs when using the Administrator account and when using an instance principal which has monitoring permission.
Here is the JSON that I am pushing to the Monitoring service:
[
{
"namespace": "myFirstNamespace",
"compartmentId": "tenant id",
"resourceGroup": "myFirstResourceGroup",
"name": "successRate",
"dimensions": {
"resourceId": "ocid1.exampleresource.region1.phx.exampleuniqueID",
"appName": "myAppA"
},
"metadata": {
"unit": "percent",
"displayName": "MyAppA Success Rate"
},
"datapoints": [
{
"timestamp": "2021-06-01T22:19:20Z",
"value": 83.0
}
]
}
]
The CLI command that I am using is:
oci monitoring metric-data post --metric-data file://metric-data.json
The OCI CLI command should be:
oci monitoring metric-data post --metric-data file://metric-data.json --endpoint https://telemetry-ingestion.{{ region }}.oraclecloud.com
replacing {{ region }} with your region.
The --endpoint https://telemetry-ingestion.{{ region }}.oraclecloud.com parameter needs to be added.
Looks like some authorization issue. Please cross check if the instance principle has all the required permission assigned. Please review this document Publishing Custom Metrics and Overview of Monitoring

FeathersJs authenticate returning NotAuthenticated: Invalid login

I am following the official guide of feathers js authenticate https://docs.feathersjs.com/guides/chat/authentication.html but it seems like even after following the guide step by step I am unable to generate tokens. Here is the body of my request to http://localhost:3030/authentication
{
"strategy": "local",
"email": "abc#foo.com",
"password": "12345678"
}
and here is the response I got
{
"name": "NotAuthenticated",
"message": "Invalid login",
"code": 401,
"className": "not-authenticated",
"data": {
"message": "Invalid login"
},
"errors": {}
}
I am using Sequilize with MySQL and I have tested my services using postman and they all are working fine (get/post data from the database)
I figured it out. It was not working because the verify method in authentication-local was verifying the password assuming that the password was hashed using their hashing utility method.
Starting the server with debug mode on have helped to figure out this issue

Can't create image from tar.gz file in bucket

I'm trying to create a custom image using Console or gcloud, i.e. (Note: URLs are masked with [naURL] to get around URL posting limitation.):
$ gcloud compute images create debian-9-1-v20170810-1 --source-uri=https:[naURL]//storage.googleapis.com/[my bucket]/compressed-image.tar.gz
The command runs for about half an hour (i.e. 1800s) and then gives the following error:
ERROR: (gcloud.compute.images.create) Could not fetch resource:
- Did not create the following resources within 1800s: https:[naURL]//www.googleapis.com/compute/v1/projects/spherical-proxy-175708/global/images/debian-9-1-v20170810-1. These operations may still be underway remotely and may still succeed; use gcloud list and describe commands or https:[naURL]//console.developers.google.com/ to check resource state
The corresponding REST record accessible via Console>Compute Engine>Operations for the item reads:
{
"kind": "compute#operation",
"id": "5371669110648613089",
"name": "operation-1502320142020-5565a2a676da1-06d76920-4c86568d",
"operationType": "insert",
"targetLink": "https:[naURL]//www.googleapis.com/compute/v1/projects/spherical-proxy-175708/global/images/debian-9-1-v20170810-1",
"targetId": "3098231522309056737",
"status": "DONE",
"user": "andree.leidenfrost#gmail.com",
"progress": 100,
"insertTime": "2017-08-09T16:09:02.501-07:00",
"startTime": "2017-08-09T16:09:03.136-07:00",
"endTime": "2017-08-09T16:59:29.128-07:00",
"error": {
"errors": [
{
"code": "INTERNAL_ERROR",
"message": "Code: '8625676013601614622'"
}
]
},
"httpErrorStatusCode": 503,
"httpErrorMessage": "SERVICE UNAVAILABLE",
"selfLink": "https:[naURL]//www.googleapis.com/compute/v1/projects/spherical-proxy-175708/global/operations/operation-1502320142020-5565a2a676da1-06d76920-4c86568d"
}
Because the HTTP error is 503 "SERVICE UNAVAILABLE" I've tried a few times over the last couple of days but the problem persists.
I'm trying to follow the instructions in document Importing Boot Disk Images to Compute Engine.
Any help or hints how to debug further would be greatly appreciated!

Google image search api. Bad request

I'm using Google CustomSearch API v1 for image search but I have a problem with my JSON request.
When I filled out the search.cse.list (here) I got the JSON request like this:
GET https://www.googleapis.com/customsearch/v1?q=test&cref=AIzaSyAreDhTh3IqaGPqC44t08sQF_qbSGzzA7Q&cx=010855067127206535986%3Aqdh_vhglb4u&fileType=jpg&filter=1&imgSize=medium&imgType=news&num=4&searchType=image&start=1&key={YOUR_API_KEY}
And the response of this request:
{
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"
},
"queries": {
...
},
"context": {
...
},
"searchInformation": {
...
},
"items": [
{
"kind": "customsearch#result",
"title": "free student testing cartoons | Home > Clipart > Cartoons ...",
"htmlTitle": "free student <b>testing</b> cartoons | Home > Clipart > Cartoons <b>...</b>",
"link": "https://s-media-cache-ak0.pinimg.com/236x/30/0c/a5/300ca57d460ab787202e36bdf0364e57.jpg",
"displayLink": "www.pinterest.com",
"snippet": "free student testing cartoons",
"htmlSnippet": "free student <b>testing</b> cartoons",
"mime": "image/jpeg",
"image": {
"contextLink": "https://www.pinterest.com/pin/568157309212095926/",
"height": 213,
"width": 236,
"byteSize": 14426,
"thumbnailLink": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQ-JefdKWd1WZkuesaq01zldYRW2JmYd_z0cW0SF9OEXFMVr6M8XZO4kg",
"thumbnailHeight": 98,
"thumbnailWidth": 109
}
},
But when I tried to use this request at the browser bar I got an error:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"extendedHelp": "https://console.developers.google.com"
}
],
"code": 403,
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
}
}
I guess that I should use Ajax call, but I dont know how can I do it, because I am beginner.
I also made an API Key, "cx" and have enabled CustomSearch API at my console.developer account.
So the question is: How can I get values from this JSON request and then operate with them if I even cant get values in my browser? I want to get an image-link from this request.
Sorry for my English.
The Google Image Search API was deprecated in 2011, and has finally, now, been switched off :( You'll have to find something else to use, sorry :(

How to get customAPI url from node.js app?

I am just starting with BlueMix and in my space I have:
a Cloud Integration service: using a Basic Secure Connection, for which I have created an API endpoint; then in that Cloud Integration service I have added the corresponding API by importing a swagger 1.2 file, and published that customAPI to my organization;
a pretty simple node.js application;
From the Cloud Integration service> API view, I can get the URLs for the different resources (for instance http://endpoint_ip:endpoint_port/api/version/path_to_resource), so I can hardcode these URLs in my node.js application and it works.
But if I bind the Cloud Integration service and even the customAPI to my node.js application, I don't get any information in VCAP_SERVICES about the endpoint URL; but I have seen examples of VCAP_SERVICES where the API URL is available.
Below is my VCAP_SERVICES
{"CloudIntegration": [
{
"name": "Cloud Integration-b9",
"label": "CloudIntegration",
"plan": "cloudintegrationplan",
"credentials": {
"userid": "apiuser#CloudIntegration",
"password": "S!2w3e40",
"apis": [
{
"name": "Catalog Manager API",
"desc": "Catalog Manager API",
"resource": ""
}
]
}
}
]
}
What I am trying to achieve is to avoid hardcoding URLs in my application, since I can bind a BlueMix service to it, and perhaps get info from the environment.
Am I doing something wrong? Or is that not the way it is supposed to work?
Also I don't really get why there is nothing in the VCAP_SERVICES.CloudIntegration[0].credentials.apis[0].resource even though I have my customAPI specifies resources.
#Rick
Make sure you "publish" your API after configuring the Cloud Integration service. Then service credentials will reflect the changes:
"CloudIntegration": [
{
"name": "Cloud Integration-v5",
"label": "CloudIntegration",
"plan": "cloudintegrationplan",
"credentials": {
"userid": "apiuser#CloudIntegration",
"password": "S!2w3e40",
"apis": [
{
"name": "SwaggerPetStore",
"desc": "SwaggerPetStore",
"resource": "http",
"baseurl": "http://mypypatchank.mybluemix.net"
}
]
}
}
]
in the same way, if you use the API management service, you will have a corresponding VCAP_SERVICES entry
"Swagger Petstore v1 : Sandbox 551b2dcf0cf2521d98d061d4 prod": [
{
"name": "Swagger Petstore v1 : Sandbox prod-w0",
"label": "Swagger Petstore v1 : Sandbox 551b2dcf0cf2521d98d061d4 prod",
"plan": "plan1 : Sandbox prod",
"credentials": {
"clientID": "55cfe3fa-ff59-474c-a1b6-46d3cc9871",
"clientSecret": "uK3xM3eF4cA1qF7yW8mC2lP6wS6aG7sQ5cL2yJ4sC6iS1dE7",
"url": "https://api.eu.apim.ibmcloud.com/garciatemx1ibmcom/sb/api"
}
}
]
Since your goal is to "to avoid hardcoding URLs in my application, since I can bind a BlueMix service to it, and perhaps get info from the environment." I would like to suggest using a user provided service.
This will create a user provided service and start interactive input for you to enter the api url and a password. You can add more parameters if you need.
cf cups servicename -p "url, password"
Bind this service to your application and restage. You can access these parameters in your Node.js application easily with the cfenv module.
var cfenv = require("cfenv");
var appEnv = cfenv.getAppEnv();
var myService = appEnv.getService("servicename");
//use myService.credentials.url to access the url value.
//use myService.credentials.password to access the password value.
The user provided services VCAP_SERVICES looks like:
{
"user-provided": [
{
"name": "servicename",
"label": "user-provided",
"credentials": {
"url": "myURL",
"password": "myPassword"
}
}
]
}