Reputation: 1
I am using Windows and REST API
and have installed the attachment plugin, restarted elasticsearch
and created the attachment
property for a particular type in _mapping
. However, I am getting an error:
I executed this:(NOT WORKING)
{
http://localhost:9200/documentsx/person/1(post)
}
{
"my_attachment" : {
"_content_type" : "application/pdf",
"_name" : "/sap1.pdf",
"content" : "... base64 encoded attachment ..."
}
}
I am getting this error: :
{
"error": "MapperParsingException[failed to parse]; nested: JsonParseException[Failed to decode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal white space character (code 0x20) as character #3 of 4-char base64 unit: can only used between units\n at [Source: [B@16dd7aa; line: 5, column: 29]]; ",
"status": 400
}
BTW if I remove the file or put some random filename above in _name
it gives the same error, I think it is not reading the file itself.
Where i am going wrong?
Upvotes: 0
Views: 674
Reputation: 88
To get rid of this error, the value of the "content" attribute needs to be a base64 encoded string. You need to read the contents of the file and convert it to a base64 encoded string and place that string in place of "... base64 encoded attachment ..." above.
Upvotes: 2