ElasticSearch illegal_argument_exception for client.bulk() Node.js - node.js

I try to send data to ES and I was using POST request to send data line by line and it worked fine with small files.
When I changed to use client.bulk(), I keep getting the following error message:
"status": 400,
"error":
{
"type": "mapper_parsing_exception",
"reason": "failed to parse [target_status_code]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "For input string: \"-\""
}
}
I noticed that after I use bulk, the type of target_status_code field has changed from string to number and many keyord fields are gone.
I only modified the sending request function so I don't understand why it doesn't work when using bulk.

Related

Why does clangd respond with "method not found" when using textDocument/didOpen?

I try to communicate with clangd. The first initialization is fine, but when trying to open a document with "textDocument/didOpen" i get the response "method not found". I cannot find any other method in the specification for opening documents. Is it the wrong method, or am I doing something else wrong?
My request
Content-Length: 1771
{
"id": 2,
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"languageId": "cpp",
"text": "file content...",
"uri": "file://src/main.cpp",
"version": 1
}
}
}
The response I get:
Content-Length: 77
{
"error": {
"code": -32601,
"message": "method not found"
},
"id": 2,
"jsonrpc": "2.0"
}
The language server protocol distinguishes between request messages which are client --> server messages to which the server will respond, and notification messages which are client --> server messages which are meant to notify the server about something and do not require a response.
The id field is only expected for request messages (it's used to associate the response with the request). However, textDocument/didOpen is a notification message. Removing the id field should fix the error.
Further reading:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage

DocuSign Envelopes: listStatus "UNSPECIFIED_ERROR"

I'm trying to make a API call to the eSignature REST API Envelopes: listStatus (as shown here)
However, I get ERROR 400 Bad Request and the following:
{
"errorCode": "UNSPECIFIED_ERROR",
"message": "Object reference not set to an instance of an object."
}
Even trying it in DocuSign's API explorer I get the same error. The error seems to be pointing to a issue with how the request body is formed. DocuSign suggests this,
{
"envelopeIds": [
"44c5ad6c-xxxx-xxxx-xxxx-ebda5e2dfe15",
"8e26040d-xxxx-xxxx-xxxx-1e29b924d237",
"c8b40a2d-xxxx-xxxx-xxxx-4fe56fe10f95"
]
}
however, if I use "envelopeIds" in the body instead I get:
{
"errorCode": "INVALID_REQUEST_PARAMETER",
"message": "The request contained at least one invalid parameter. Query parameter 'from_date' must be set to a valid DateTime, or 'envelope_ids' or 'transaction_ids' must be specified."
}
replacing "envelopeIds" with "envelope_ids" I get:
Response:
{
"errorCode": "UNSPECIFIED_ERROR",
"message": "Object reference not set to an instance of an object."
}
and even using a comma separated list like, I get the same error:
Body:
{ "envelopeIds": "44c5ad6c-xxxx-xxxx-xxxx-ebda5e2dfe15,8e26040d-xxxx-xxxx-xxxx-1e29b924d237"}
Response:
{
"errorCode": "UNSPECIFIED_ERROR",
"message": "Object reference not set to an instance of an object."
}
Any help would be much appreciated. I have tried this using both postman and DocuSign's API explorer.
You need to include ?envelope_ids=request_body in the URL.
Then it should work with the body:
{
"envelopeIds": [
"44c5ad6c-xxxx-xxxx-xxxx-ebda5e2dfe15",
"8e26040d-xxxx-xxxx-xxxx-1e29b924d237",
"c8b40a2d-xxxx-xxxx-xxxx-4fe56fe10f95"
]
}

Want to pass multiple enum values for PageSpeed Insights API

I'm trying to use PageSpeed Insights API. The API Reference indicates that I can pass multiple category values when calling the API.
I issued the below command. Category values are separated with commas.
curl 'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?key=<my key>&url=<my url>&category=ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO'
The API responds with the below JSON.
{
"error": {
"code": 400,
"message": "Invalid value at 'category' (TYPE_ENUM), \"ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO\"",
"errors": [
{
"message": "Invalid value at 'category' (TYPE_ENUM), \"ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO\"",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT"
}
}
I have no idea how I can pass multiple category values. Does anyone know how to do that?
Pass as seperate parameter rather than comma seperated.
curl 'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?key=<my key>&url=<my url>&category=ACCESSIBILITY&category=BEST_PRACTICES&category=PERFORMANCE&category=PWA&category=SEO'

How to extract a substring value from Json response in SOAPUI

I am trying to fetch the requestID from the message which is a string.
{
"version": "1.0.0-80",
"status": 201,
"error": "MSG004",
"uuid": "aae1bb59-da3f-4118-a4a4-asdfsdfsd",
"message": "Successfully created a request with an id of 1234",
"path": "/api/request/",
"timestamp": "2019-03-21T09:41:58.484"
}
Can anyone help me with creating a property from message, I only need to pass request id in the end of this sentence:
"Successfully created a request with an id of 1234"
Thanks
Using a straight-forward substring should do the trick.
def id = variableThatContainsTheString.substring(46)
This however is not pretty. But nor is the solution you are testing.
I would argue that if the ID is something that should be used by the consumer of the webservice, then it really should be delivered in a key-value of its own. There should be no need to cut it from a string.
The response could then be something like this:
{
"version": "1.0.0-80",
"status": 201,
"error": "MSG004",
"uuid": "aae1bb59-da3f-4118-a4a4-asdfsdfsd",
"message": "Successfully created a request with an id of 1234",
"path": "/api/request/",
"timestamp": "2019-03-21T09:41:58.484",
"id": "1234"
}
Tell the developers to get their act together. ;-)

Outlook Mail REST API: send message with attachment

I'm trying to use next API method: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessages. Sending messages without attachments works just fine, but I can not understand how to send message with attachments.
According to docs, Message structure can contain array of Attachments with items of type https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesFileAttachment . Problem is in the field ContentBytes -- it is impossible to dump bytes to JSON before sending request to this API method (actually dumping any BLOB to JSON is nonsense).
How should I pass Attachments using REST API at all?
Thanks.
There's an example of passing the attachment on that page: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessageOnTheFly
I know I'm 3 years late but, you can look at this example:
https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#create-and-send-messages (if you don't get forwarded to the section "Create and send messages", please scroll manually).
I know it is 365 and not Microsoft Graph but request is absolutely same.
This is basically how JSON representation of the post method looks:
https://outlook.office.com/api/v2.0/me/sendmail
{
"Message":
{
"Subject": "Meet for lunch?",
"Body": {
"ContentType": "Text",
"Content": "The new cafeteria is open."
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}
],
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
}
}

Resources