Can't find Graphite metrics using Cubism.js - graphite

The following command returns the metrics as expected:
curl "http://graphite.metrics:8080/metrics/find?format=completer&query=server*.cache"
{"metrics": [
{"is_leaf": "1", "path": "server1200.cache", "name": "cache"},
{"is_leaf": "1", "path": "server1201.cache", "name": "cache"},
{"is_leaf": "1", "path": "server1202.cache", "name": "cache"},
{"is_leaf": "1", "path": "server1203.cache", "name": "cache"},
{"is_leaf": "1", "path": "server1205.cache", "name": "cache"}
]
}
If I try the same query using Cubism.js, I get a "unable to find metrics":
var context = cubism.context()
.serverDelay(60 * 1000)
.step(60 * 1000)
.size(1440);
var graphite = context.graphite("http://graphite.metrics:8080");
graphite.find("metricXX*", function(error, results){
alert(error);
});
Why Cubism.js can't find the metrics if it internally does the same request?

It was not a Cubism.js bug after all. Actually, it was a Cross-site HTTP request.
I enabled the Web Developer Extention in the Chrome and noticed the message:
origin is not allowed by Access-Control-Allow-Origin
And fixed adding the code below in the Node.js:
var server = http.createServer(function (req, res) {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "X-Requested-With");
proxy.proxyRequest(req, res);
});

Related

Invalid patch error in Contentful CMA client

I am trying to populating an empty field by using patch method in Contentful. The following piece of code works in one cloned environment but does not work in another.
let patchData: OpPatch[] = [
{
op: 'replace',
path: '/fields/keywords',
value: entryKeyword,
},
];
await cmaClient.entry.patch({ entryId: entryId }, patchData, { 'X-Contentful-Version': entryVersion });
When I try to execute this, receiving a 'Unprocessable Entity' error:
UnprocessableEntity: {
"status": 422,
"statusText": "Unprocessable Entity",
"message": "Could not apply patch to entry: invalid patch",
"details": {},
"request": {
"url": "/spaces/xyz/environments/abc/entries/123456789",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json-patch+json",
"X-Contentful-User-Agent": "sdk contentful-management-plain.js/7.54.2;",
"Authorization": "Bearer ...",
"user-agent": "node.js/v14.19.2",
"Accept-Encoding": "gzip",
"X-Contentful-Version": 25,
"Content-Length": 78
},
"method": "patch",
"payloadData": "[{\"op\":\"replace\",\"path\":\"/fields/keywords\",\"value\":\"test keyword\"}]"
},
"requestId": "abcd-123456"
}
I have the same exact access permissions to both environments. What am I missing out on?
I had the same issue - turned out when the entry doesn't have the filed you're trying to patch - it will throw an error like above.

Add user to SharePoint group using Power Automate

I would like to use Power Automate to add a user in as a member to a SharePoint Site using HTTP request.
The flow continues to fail on me and I'm wondering if anyone managed to do this successfully in the past?
I got the Group ID from :
https://{org name}.sharepoint.com/sites/{site name}/_api/web/id
I have attached included the input and output of the HTTP Request (within flow) below
Raw Inputs
{
"host": {
"connectionReferenceName": "shared_sharepointonline",
"operationId": "HttpRequest"
},
"parameters": {
"dataset": "https://{REDACTED}.sharepoint.com/",
"parameters/method": "POST",
"parameters/uri": "_api/web/sitegroups(547ea631-f9d4-411a-a3f5-8af3d5e6225b)/Users",
"parameters/headers": {
"accept": "application/json;odata.metadata=none",
"content-type": "application/json"
},
"parameters/body": "{'LoginName':'i:0#.f|membership|{REDACTED}#{REDACTED}.com'}"
}
}
Raw Outputs
{
"statusCode": 400,
"headers": {
"Pragma": "no-cache",
"x-ms-request-id": "cb6ab59f-909a-2000-ac2f-2217e416179a",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
"Cache-Control": "no-store, no-cache",
"Set-Cookie": "{REDACTED};Path=/;HttpOnly;Secure;Domain=sharepointonline-we.azconn-we.p.azurewebsites.net,ARRAffinitySameSite={REDACTED}24;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-we.azconn-we.p.azurewebsites.net",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "true",
"Date": "{TIME & DATE}",
"Content-Length": "457",
"Content-Type": "application/json",
"Expires": "-1"
},
"body": {
"status": 400,
"message": "The expression \"web/sitegroups(547ea631-f9d4-411a-a3f5-8af3d5e6225b)/Users\" is not valid.\r\nclientRequestId: 1cc16a39-7d9c-4290-b07d-4c7329611fb8\r\nserviceRequestId: cb6ab59f-909a-2000-ac2f-2217e416179a",
"source": "https://{REDACTED}.sharepoint.com/_api/web/sitegroups(547ea631-f9d4-411a-a3f5-8af3d5e6225b)/Users",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
}
The error I get is:
"The expression "web/sitegroups(547ea631-f9d4-411a-a3f5-8af3d5e6225b)/Users" is not valid.
clientRequestId: 1cc16a39-7d9c-4290-b07d-4c7329611fb8
serviceRequestId: cb6ab59f-909a-2000-ac2f-2217e416179a"
This makes me think the group ID is incorrect. Can someone please advise if this is incorrect or if I have maybe formatted the uri incorrectly?
Try to use the body like this:
{
'__metadata': {
// Type that you are modifying.
'type': 'SP.User'
},
'LoginName': '<<User Login Name>>'
}

Create a document in Cosmos DB via Logic App and PartitionKey mismatch in document & header

So I'm trying to create an Azure Logic App which will create a new record inside a Cosmos DB collection to store review results.
I've created a Cosmos DB database (called icecream) + collection (called reviews). The PartitionKey of the reviews collection is /flavorIdentifier.
In my Logic App I have a step which inserts a new document.
The code looks like this.
"Create_review": {
"inputs": {
"body": {
"flavor": "#{body('JSON_parseren_2')?['flavor']}",
"flavorIdentifier": "#{body('JSON_parseren')?['itemOrdered']}",
"id": "#{guid()}",
"review": "#{body('E-mail_met_opties_verzenden')?['SelectedOption']}"
},
"headers": {
"x-ms-documentdb-raw-partitionkey": "#body('JSON_parseren')?['itemOrdered']"
},
"host": {
"connection": {
"name": "#parameters('$connections')['documentdb']['connectionId']"
}
},
"method": "post",
"path": "/dbs/#{encodeURIComponent('icecream')}/colls/#{encodeURIComponent('reviews')}/docs"
},
"runAfter": {
"E-mail_met_opties_verzenden": [
"Succeeded"
]
},
"type": "ApiConnection"
},
So, I'm posting the message to Cosmos DB
{
"flavor": "My flavor",
"flavorIdentifier": "3",
"id": "4927042a-faa1-4e09-9c6d-d038ef659b25",
"review": "Very satisfied"
}
As you can see, I also specified the partition key to the same value as flavorIdentifier.
My guess is this should just work. But it doesn't
The error I'm receiving states
PartitionKey extracted from document doesn't match the one specified in the header
Which is strange, as both have the same value, also when checking the raw input and output. Is there anything I'm overlooking?
For completeness, the full input and output of this step.
The raw input of the failed step.
{
"host": {
"connection": {
"name": "/subscriptions/3b3729b4-021a-48b5-a2eb-47be0c7e7f44/resourceGroups/developerday-workshop/providers/Microsoft.Web/connections/documentdb"
}
},
"method": "post",
"path": "/dbs/icecream/colls/reviews/docs",
"headers": {
"x-ms-documentdb-raw-partitionkey": "3"
},
"body": {
"flavor": "My flavor",
"flavorIdentifier": "3",
"id": "4927042a-faa1-4e09-9c6d-d038ef659b25",
"review": "Very satisfied"
}
}
The raw output of the failed step.
{
"statusCode": 400,
"headers": {
"x-ms-last-state-change-utc": "Wed,27 Mar 2019 05:03:54.568 GMT",
"lsn": "1",
"x-ms-schemaversion": "1.7",
"x-ms-quorum-acked-lsn": "1",
"x-ms-substatus": "1001",
"x-ms-current-write-quorum": "3",
"x-ms-current-replica-set-size": "4",
"x-ms-xp-role": "1",
"x-ms-global-Committed-lsn": "1",
"x-ms-number-of-read-regions": "0",
"x-ms-transport-request-id": "1",
"x-ms-cosmos-llsn": "1",
"x-ms-cosmos-quorum-acked-llsn": "1",
"x-ms-session-token": "1",
"x-ms-request-charge": "1.24",
"x-ms-serviceversion": "version=2.2.0.0",
"x-ms-activity-id": "bd428162-ec1a-4f50-879a-04b8ca0817a1",
"Strict-Transport-Security": "max-age=31536000",
"x-ms-gatewayversion": "version=2.2.0.0",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "false",
"Date": "Wed, 27 Mar 2019 11:39:57 GMT",
"Content-Length": "1149",
"Content-Type": "application/json"
},
"body": {
"code": "BadRequest",
"message": "Message: {\"Errors\":[\"PartitionKey extracted from document doesn't match the one specified in the header\"]}\r\nActivityId: bd428162-ec1a-4f50-879a-04b8ca0817a1, Request URI: /apps/9bc5d0cc-9b7c-4b1d-9be2-0fa2654271c4/services/9d84c048-383b-498e-8472-1f57da72135d/partitions/0f29761a-9ffc-4560-94ce-0328c3c79f92/replicas/131981366274575376p/, RequestStats: \r\nRequestStartTime: 2019-03-27T11:39:57.0795308Z, RequestEndTime: 2019-03-27T11:39:57.0995601Z, Number of regions attempted: 1\r\nResponseTime: 2019-03-27T11:39:57.0995601Z, StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-westeurope1-fd21.documents.azure.com:16833/apps/9bc5d0cc-9b7c-4b1d-9be2-0fa2654271c4/services/9d84c048-383b-498e-8472-1f57da72135d/partitions/0f29761a-9ffc-4560-94ce-0328c3c79f92/replicas/131981366274575376p/, LSN: 1, GlobalCommittedLsn: 1, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 1001, RequestCharge: 1.24, ItemLSN: -1, SessionToken: 1, UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Create\r\n, SDK: Microsoft.Azure.Documents.Common/2.2.0.0"
}
}
Any thoughts?
Please add double quotation marks "" around your partition key and it works fine for me.
View the code:

Making a POST call in R

I have a rest API to which I want to make a POST call.
The API is
"http://swift-rand-8888a.stg.corp.dummy.com/random/filter"
It doesn't need an Auth parameter.
The payload I am trying to send is:
Payload: { "name": "Filter_1533141396310", "shortName": "LHF",
"filterType": "==", "value": {
"name": "completed",
"defaultValue": "completed" }, "attribute": {
"vName": "status",
"vType": "LOCAL" }, "transformerDependency": "", "createdBy": "Aman" }
Header should be {Content-Type=[application/json]}
I am always getting "bad request error".
My code looks like:
dummy<-"Payload: {'name': 'Filter_1533141396310','shortName': 'LHF','filterType': '==','value': {'name': 'completed','defaultValue': 'completed'},'attribute': {'vName': 'status','vType': 'LOCAL'},'transformerDependency': '','createdBy': 'Prateek'}"
result <- POST("http://swift-rand-8888a.stg.corp.dummy.com/random/filter",
body = dummy,
add_headers("Content-Type=[application/json]"))
Output <- content(result)
Can someone help me with my mistake?

Basic Auth header not sent (Swagger)

I have a basic auth secured API but after filling in the authentication credentials, it does not apply to request header. I saw"ERROR Server not found or an error occurred " at swagger editor and "401 Unauthorized" on fiddler.
User Name and Pwd : odata and qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=
Here is my swagger json
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Basic Auth Example",
"description": "An example for how to use Basic Auth with Swagger.\nServer code is available [here](http://navm3.cloudapp.net:90/nav/odata). It's running on NAVM3.\n\n**You can use below User Name and Password for test.**\n* User Name: `ODATA`\n* Password: `qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=`\n"
},
"host": "navm3.cloudapp.net:90",
"basePath": "/nav/odata",
"schemes": [
"http"
],
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
}
},
"paths": {
"/": {
"get": {
"security": [
{
"basicAuth": []
}
],
"responses": {
"200": {
"description": "Will send `Authenticated` if authentication is succesful, otherwise it will send `Unauthorized`"
}
}
}
}
}
}
i had the same problem, but the problem was in nodeJS back-end.
If you are using NodeJS, probably the problem it is with CORS. You should enable CORS in NodeJS with Express and everything will work.
To enable the CORS in nodeJS you can add the below code, before of the routes.
var app = express();
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, UPDATE, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
next();
});
try to replace the following part:
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
}
},
with the following
"securityDefinitions": {
"basicAuth": {
"type": "http",
"scheme": "basic"
}
},
keeping the rest as is
here is the reference https://swagger.io/docs/specification/authentication/basic-authentication/

Resources