Rocket.Chat REST API "/api/v1/users.register" Not Reponding - rocket.chat

Description:
Requesting to endpoint: "/api/v1/users.register" is not responding on my self-hosted Rocket.Chat server running on docker.
The rest of the APIs seem to be fine and only this one is not sending back 200 OK HTTPS response and I face the request timed out.
Although the requested JSON data has been sent to the server and the requested user has been registered cause if I try to send the same request again I get the 400 Bad Request with the error: "Username is already in use".
Steps to reproduce:
curl -H "Content-type:application/json"
http://localhost:3000/api/v1/users.register
-d '{ "username": "rogersmith", "email": "roger#example.com", "pass": "passw0rd", "name": "Roger Smith"}'
Expected behavior:
HTTP status code: 200 Ok
JSON result:
{
"user": {
"_id": "nSYqWzZ4GsKTX4dyK",
"type": "user",
"status": "offline",
"active": true,
"name": "Example User",
"utcOffset": 0,
"username": "example"
},
"success": true
}
Actual behavior:
Literally nothing!
Server Setup Information:
Version of Rocket.Chat Server: 3.11.0
Operating System: Ubuntu Linux 18.04.2
Deployment Method: docker-compose
MongoDB Version: 4.0.0

Related

403 Forbidden on Microsoft Teams RSC graph api calls, except on own tenant

I'm working on a Microsoft Teams tab and am planning to use some of the new RSC endpoints to retrieve members of the Team/group the app has been added to.
I have followed all steps from the RSC docs looked at the RSC sample code but still have an issue making Graph API calls to the beta rsc endpoints.
I have listed the RSC permission in the Teams manifest:
"webApplicationInfo": {
"id": "{AD_APP_CLIENT_ID}",
"resource": "https://notapplicable"
},
"showLoadingIndicator": true,
"authorization": {
"permissions": {
"orgWide": [],
"resourceSpecific": [
{
"name": "Member.Read.Group",
"type": "Application"
},
{
"name": "TeamSettings.Read.Group",
"type": "Application"
},
{
"name": "ChatSettings.Read.Chat",
"type": "Application"
},
{
"name": "ChatMember.Read.Chat",
"type": "Application"
},
{
"name": "ChannelSettings.Read.Group",
"type": "Application"
},
{
"name": "TeamMember.Read.Group",
"type": "Application"
}
]
}
}
Query Graph API like so:
GET https://graph.microsoft.com/beta/teams/{{group_id}}/channels/{{channel_id}}
Authorization: Bearer {{access_token}}
content-type: application/json
Where access_token is retrieved like so:
POST https://login.microsoftonline.com/{{ad_tenant_id}}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id={{ad_app_client_id}}&client_secret={{ad_app_client_secret}}&scope=https://graph.microsoft.com/.default
When I make the GET request to a group+channel which is in the same AAD as where the AAD Application is registered it works fine and information is returned. However, when I run the exact same code on a group+channel which is in a different AD it returns 403 Forbidden.
{
"error": {
"code": "Forbidden",
"message": "Missing role permissions on the request. API requires one of 'TeamMember.Read.All, TeamMember.ReadWrite.All, Group.Read.All, Group.ReadWrite.All, TeamMember.Read.Group, Member.Read.Group'. Roles on the request 'Group.Selected'. Resource specific consent grants on the request ''.",
"innerError": {
"date": "2022-04-06T14:13:26",
"request-id": "ce212ed2-48dc-4a8e-a7ea-4172d0cfd4c4",
"client-request-id": "ce212ed2-48dc-4a8e-a7ea-4172d0cfd4c4"
}
}
}
The response mentions "Resource specific consent grants on the request ''." which seems to suggest it's either missing a header or another access token.
As mentioned before, this exact same code works perfectly fine when I use a group_id and channel_id from within the same AD tenant.
What other steps need to be done to get RSC calls working?

graphql-mesh: why odata handler throws error when serving my local endpoint

I am trying to follow the example in the GraphQL-Mesh and replace the endpoint with my own to see how it works. Default github example works however when I try to server the mesh for my example, it throws the following error:
$ "C:\Kiran\example\GraphQLMesh\node_modules\.bin\graphql-mesh" serve
Debugger listening on ws://127.0.0.1:64627/889629dc-8f00-446e-8927-5bdcd2791e10
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
(node:13408) ExperimentalWarning: The fs.promises API is experimental
error: Unable to serve mesh: Cannot read property 'concat' of undefined {"stack":"TypeError: Cannot read property 'concat' of undefined\n at schemas.forEach (C:\\Kiran\\example\\GraphQLMesh\\node_modules\\#graphql-mesh\\odata\\index.cjs.js:493:51)\n at Array.forEach (<anonymous>)\n at ODataHandler.getMeshSource (C:\\Kiran\\example\\GraphQLMesh\\node_modules\\#graphql-mesh\\odata\\index.cjs.js:471:67)\n at process._tickCallback (internal/process/next_tick.js:68:7)"}
Waiting for the debugger to disconnect...
Done in 9.93s.
Waiting for the debugger to disconnect...
my .meshrc.yaml is very simple as shown below
sources:
- name: Mytest
handler:
odata:
baseUrl: http://localhost:6001/odata/v1/
batch: multipart
expandNavProps: true
serve:
exampleQuery: northwind-example.graphql
and package.json also is just copy of what is in the github
{
"name": "odata-example",
"version": "0.7.30",
"license": "MIT",
"private": true,
"scripts": {
"start": "graphql-mesh serve"
},
"dependencies": {
"#graphql-mesh/cli": "^0.12.1",
"#graphql-mesh/odata": "0.7.1",
"graphql": "^15.4.0"
}
}
When I hit the odata endpoint (http://localhost:6001/odata/v1/) on Postman, I see the following response:
Header
Status Code: 200 OK
content-type: application/json; odata.metadata=minimal; odata.streaming=true; charset=utf-8
date: Sat, 05 Dec 2020 06:52:51 GMT
odata-version: 4.0
server: Kestrel
transfer-encoding: chunked
Response
{
"#odata.context": "http://localhost:6001/odata/v1/$metadata",
"value": [{
"name": "Products",
"kind": "EntitySet",
"url": "Products"
}, {
"name": "Categories",
"kind": "EntitySet",
"url": "Categories"
}, {
"name": "Suppliers",
"kind": "EntitySet",
"url": "Suppliers"
}]
}
My example query is also very simple as shown below:
query fetchCatagories {
myCatagories {
CategoryId
CategoryName
Description
Products {
ProductName
OrderDetails {
OrderId
}
}
Catagories(queryOptions: { top: 1 }) {
Description
}
}
}
What am I missing in my example to get the mesh working and generating the GraphQL endpoint?
Also do I really need an example.graphql for OData as any OData service will have /$metadata endpoint that exposes the schema?
Update 1
Also I cannot get this to work with public odata endpoint like https://services.odata.org/V3/OData/OData.svc/
only the default example endpoints work
https://graph.microsoft.com/${GRAPH_VERSION:v1.0}
https://services.odata.org/TripPinRESTierService/(S(qzsyox3345c15qeq305pblvw))/
What is going on here?
if you run in to this issue, its a bug in the odata module and PR fix is available here

How to send error response as json in Grpc using envoy-proxy

I am throwing error from grpc service using resonseObserver.onError() but I am not getting messages in json format while hitting REST API from rest client, though the positive scenario is working fine and giving response as json.
I am using envoy as a transcoder, can anyone help me with how to get error response also as json. Currently I am getting BadRequest on error scenarios. The project is in SpringBoot.
TIA
You can use convert_grpc_status: true for do this.
http_filters:
- name: envoy.filters.http.grpc_json_transcoder
typed_config:
"#type": type.googleapis.com/envoy.extensions.filters.http.grpc_json_transcoder.v3.GrpcJsonTranscoder
proto_descriptor: "/tmp/envoy/proto.pb"
services: ["xxxxxxxx"]
convert_grpc_status: true
print_options:
always_print_primitive_fields: true
always_print_enums_as_ints: false
preserve_proto_field_names: false
If you mean return details key like this:
{
"code": 3,
"message": "API call quota depleted",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ResourceInfo",
"resourceType": "xxxxxx",
"resourceName": "",
"owner": "",
"description": ""
}
]
}
You MUST compile you .proto file with:
import "google/rpc/error_details.proto";
because Envoy can't deserialize binary details from your backend server without error types.
Also you can read how you can send detailed error response with Python: How to send error details like as BadRequest

GoCardless API using Classic ASP

I'm creating the following request in vbscript and sending to the gocardless sandbox:
url="https://api-sandbox.gocardless.com/"
typ="GET"
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open typ, url, False
xml.setRequestHeader "Authorization", "Bearer " & GCAccessToken
xml.SetRequestHeader "GoCardless-Version", "2015-07-06"
xml.SetRequestHeader "Accept","application/json"
xml.SetRequestHeader "Content-Type", "application/json"
xml.Send
GetGC = xml.responseText
Set xml = Nothing
The response I always get despite any tweaks I do is:
{"error":{"message":"not found","errors":[{"reason":"not_found","message":"not found"}],"documentation_url":"https://developer.gocardless.com/api-reference#not_found","type":"invalid_api_usage","request_id":"0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009","code":404}}
Any help would be appreciated. Have successfully done similar for Stripe but now need to use GC.
If you read the response from the API
{
"error": {
"message": "not found",
"errors": [{
"reason": "not_found",
"message": "not found"
}
],
"documentation_url": "https://developer.gocardless.com/api-reference#not_found",
"type": "invalid_api_usage",
"request_id": "0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009",
"code": 404
}
}
The error appears to be a HTTP status code (as is common with RESTful APIs) - 404 Not Foundlooking at the documentation link provided in the response;
404
Not Found. The requested resource was not found or the authenticated user cannot access the resource. The response body will explain which resource was not found.
So the issue could be;
You have failed to authenticate using the token in the code provided.
You authenticated but don't have permission to access the resource.
The resource you are looking for does not exist.
In this particular instance, I would suggest it is because the resource doesn't exist as the code doesn't specify a resource, only the base URL of the API which won't constitute an API endpoint you can interact with.
Looking at the documentation it's clear you need to provide a valid endpoint in the URL, at the time of writing there are 15 core endpoints to interact with along with 2 helper endpoints.
For example, a create payment request/response would look like;
POST https://api.gocardless.com/payments HTTP/1.1
{
"payments": {
"amount": 100,
"currency": "GBP",
"charge_date": "2014-05-19",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"links": {
"mandate": "MD123"
}
}
}
HTTP/1.1 201 (Created)
Location: /payments/PM123
{
"payments": {
"id": "PM123",
"created_at": "2014-05-08T17:01:06.000Z",
"charge_date": "2014-05-21",
"amount": 100,
"description": null,
"currency": "GBP",
"status": "pending_submission",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"amount_refunded": 0,
"links": {
"mandate": "MD123",
"creditor": "CR123"
}
}
}
Unfortunately, the code sample provided in the question doesn't really do anything so it's difficult to suggest what you are trying to do. In conclusion, I would suggest re-visiting the documentation for the API and look through the samples provided.

SonarQube 6.7 LTS group permissions API doesn't working

I'm migrating SonarQube from 5.6 version to 6.7. I'm using SonarQube API with my Jenkins jobs and the problem is the API for groups permissions isn't working with 6.7 version...
I've tried manually with Postman (POST raw JSON) this :
{
"groupName": "project-name-admin",
"permission": "admin",
"projectKey": "project-name"
}
The result returned is :
{
"errors": [
{
"msg": "Group name or group id must be provided"
}
]
}
And it's the same if I use :
{
"groupId": 53,
"permission": "admin",
"projectKey": "project-name"
}
or
{
"groupId": 53,
"groupName": "project-name-admin",
"permission": "admin",
"projectKey": "project-name"
}
It's working with 6.5 verison and I've no idea where this problem may come from :(
#SonarQube developers team : can you fix thaaaat please ?
Send data as application/x-www-form-urlencoded or form-data.
SonarQube Web API doesn't handle POST body in raw JSON format. See this question about Java ServletRequest to know more (Tomcat is used under the hood).
This is a piece of code to assign a project to a gate, using authentication and post. Mind the body and content-type!
// format post, sonarqube only knows form encoded
def body = sprintf("gateId=%s&projectKey=%s", ["${gateId}", "${projectKey}"])
// post to associate project with gate
result = httpRequest (
consoleLogResponseBody: true,
authentication: '<My Jenkins Credential>',
contentType: 'APPLICATION_FORM',
httpMode: 'POST',
ignoreSslErrors: true,
requestBody: "${body}",
url: "http://<sonarqube.url>/api/qualitygates/select"
)

Resources