REST API, POST Rich Text Item to Domino server - rest

i am trying to use the REST-API of my domino lotus notes server (9.0.1FP8)
It works for simple text-fields but if I try to add an rich-text-item as json, the domino server receives only the text-fields and the richt-text field is empty.
I try it with Postman and a Postrequest to http://localhost/Test/JSON_Vie…s/name/List?form=mainForm,
where I send the json
{
"title":"test rich text",
"artist":"rich texter",
"ntracks":1,
"attachments": {
"type": "multipart",
"content": [
{
"contentType": "multipart/alternative; Boundary=\"0__=4EBB0925DFBB40F18f9e8a93df938690918c4EBB0925DFBB40F1\"",
"contentDisposition": "inline"
},
{
"contentType": "text/plain; charset=US-ASCII",
"data": "test rich text",
"boundary": "--0__=4EBB0925DFBB40F18f9e8a93df938690918c4EBB0925DFBB40F1"
},
{
"contentType": "text/html; charset=US-ASCII",
"contentDisposition": "inline",
"data": "<html><body><font size=\"2\" face=\"sans-serif\"><b>test rich text</b></font></body></html>",
"boundary": "--0__=4EBB0925DFBB40F18f9e8a93df938690918c4EBB0925DFBB40F1"
}
]
}
}
The mask mainForm has the text-fields "title", "artist" , "ntracks" and the rich text-field "attachments".
How can I send an image as json and what is "boundary"?
Have you any idea , what's going wrong?

According to the documentation from IBM you need to use PUT (instead of POST) in order to update the fields.

After experimenting a little bit, I now know what was wrong. If I do the POST on the address http://localhost/Test/JSON_Views.nsf/api/data/documents?form=mainForm it works with the attachment. If I use http://localhost/Test/JSON_Views.nsf/api/data/collections/name/List?form=mainForm&computewithform=true the attachment field is ignored. But maybe you can explain me, what the extra field boundary is and if I can set the contentLocation by the name of my attachment?

Related

Http with Azure AD - Graph API - POST Method - Powerapps

I'm not able to send a POST or PATCH action thru the connector because I can't figure out how to compose the body correctly.
I try it that way:
But I get this error:
I try it without brakets, with more brakets, with single, double and without quotations but it seems nothing works.
Please can anyone tell me how to compose the body in the right way?
Thx!
Look like the body is not a valid json. Properties givenName, surname, etc. should be wrapped by quotes.
{
"givenName": "Microsoft",
"surname": "Graph",
"emailAddresses": [
{
"address": "Microsoft.graph#api.com",
"name": "Microsoft Graph"
}
],
"businessPhones": [
"+334100100"
],
"mobilePhone": "+9857665765"
}

What is the format to upload content to confluence by REST?

I found some information about the REST interface of Confluence (https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/#content-update), but I have not understood yet which format is expected for the content of the page that should be created or updated.
Is it HTML? Or the Confluence Wiki markup? Or something else?
Note that I am not interested in Confluence Cloud, only on premise.
The rest/api/content/ accepts
{
"type": "page",
"title": "`some title",
"space": {
"key": "ICXMV"
},
"body": {
"wiki": {
"value": "h1. Hello world!",
"representation": "wiki"
}
}
}
So it is possible to upload content in the Confluence Wiki format.

Delphi XE5: Problems with proper visualization of extracted GMail emails

I am facing some trouble in properly visualizing emails extracted from GMail. I use the GMail API to retrieve the messages. This part seems to be working properly and I get the json with the entire message.
Here is a small part of one of the body parts
"mimeType": "multipart/alternative",
"filename": "",
"headers": [
{
"name": "Content-Type",
"value": "multipart/alternative; boundary=001a114710d029267205278f13b9"
}
],
"body": {
"size": 0
},
"parts": [
{
{
"partId": "0.0",
"mimeType": "text/plain",
"filename": "",
"headers": [
{
"name": "Content-Type",
"value": "text/plain; charset=UTF-8"
},
{
"name": "Content-Transfer-Encoding",
"value": "quoted-printable"
}
],
"body": {
"size": 549,
"data": "SGkgUGF1bCwNCg0KQXBvbG9naWVzLCBidXQgSSBmb3Jnb3QgdG8gbWVudGlvbiB0aGF0IHRoZSByZXN0IG9mIHlvdXIgb3JkZXIgaGFzIGJlZW4NCnNlbnQgb3V0IGluIHRoZSBtZWFudGltZQ0KDQpNYW55IHRoYW5rcw0KDQoqS2luZCBSZWdhcmRzKg0KKkJhcmJhcmEgSm9uZXMqDQoqSW50ZXJuZXQgU2FsZXMqDQoNCipPbGQgTWlsbCBTYWRkbGVyeSoNCg0KKnd3dy5zYWRkbGVyeS5iaXogPGh0dHA6Ly93d3cuc2FkZGxlcnkuYml6Lz4qDQoNCipUZWw6ICs0NCAoMCkyOCA5MzM1IDMyNjggPCUyQjQ0JTIwJTI4MCUyOTI4JTIwOTMzNSUyMDMyNjg-Kg0KDQoqVGFrZSBhIFZpcnR1YWwgdG91ciBvZiBvdXIgc2hvcCoNCkdvb2dsZSBwbGFjZXMgaHR0cDovL2dvby5nbC85Y1o5ZDANCipbaW1hZ2U6IElubGluZSBpbWFnZXMgNF1XaXNoaW5nIHlvdSBhIHZlcnnigItbaW1hZ2U6IElubGluZSBpbWFnZXMgM10qDQoqICAgICAgICAgICAgICAgICAgTWVycnkgQ2hyaXN0bWFzKg0KDQoq4oCLICAg4oCLICDigIsgICAgW2ltYWdlOiBJbmxpbmUgaW1hZ2VzIDJd4oCLKg0K"
}
}
So what is the data part encoded with? I am getting confused with the "Content-Transfer-Encoding" ->"quoted-printable". Should I decode the value of the data using a "quoted-printable" decoder or not?
Initially without noticing the "quoted-printable" value, I decoded the data value using DecodeBase64, here is how I am making it
function TViewEmailsForm.DecodeData(aStr: String): String;
var
aStrm: TBytesStream;
aStrStrm: TStringStream;
begin
Result := '';
if aStr = '' then
Exit;
aStrm := TBytesStream.Create(DecodeBase64(aStr));
aStrStrm := TStringStream.Create;
try
aStrm.Position := 0;
aStrStrm.LoadFromStream(aStrm);
Result := aStrStrm.DataString;
finally
aStrm.Free;
aStrStrm.Free;
end;
end;
Using that returns human readable text, however at the end something more is decoded and I don't get what it is. I presume it is some kind of formatting bold text, link, kind of signature but I don't succeed in anyway to show it properly (not sure what to use though as component - RichEdit, HTMLViewer)
The end of the decoded string looks like
.......
*Name of the company*
*website of the company <again the website of the company>*
*Tel: +44 (0)28 9335 3268 <%2B44%20%280%2928%209335%203268
ѓBѓBЉ•ZЩHHљ\ќX[Э\€Щ€Э\€ЪЬ
ѓB‘ЫЫЩЫHXЩ\И‹ЛЩЫЫЛ™ЫОXЦЋYBЉ–Ъ[XYЩN€[›[™H[XYЩ\И
UЪ\Ъ[™И[ЭHH™\ћx "ЦЪ[XYЩN€[›[™H[XYЩ\ИЧJѓBЉ€Y\њћHЪљ\ЭX\КѓBѓBЉё "И8 "И8 "ИЪ[XYЩN€[›[™H[XYЩ\И—x "КѓB›
I have some other messages which pretend to have html body, but again the data is seen in that way. I tried to load this string into the lines of TRichEdit, but had no luck, I tried to use TIdDecoderQuotedPrintable to decode this string, though I am not sure if I have to make it, but some of the characters got replaced by '?' (question marks)
What I am missing here and what is the proper way of visualizing the content of the messages?
After serious research and testing different encoders/decoders I finally managed to properly decode what was encoded in the message.
I used Indy's TIdEncoderMIME found in IdCoderMIME and used the DecodeString method. The HTML messages and bodies are properly decoded too with it.
Hope this will help other people not to spend two days in "fighting" with decoding messages!
EDIT: I noticed that the symbol > comes as ? Maybe there something else which has to be done?
EDIT2: It seems that the encoding of the data is not actually Base64 but Base64Url. On the following link http://blog.marcocantu.com/blog/delphi_facebook_base64_encoding.html you can find interesting post on that. The images are encoded in that way and the standard decoding doesn't work for extracting them.
Whoever knows French can read something here too http://codes-sources.commentcamarche.net/source/51156-base64-base64url-encode-decode

Facebook - "attachments" modifier - get all possible types

I create a script which will embed all posts from my group on my website. To do that, I have to know all possible types of modifier "attachments".
Now I know, that type can be:
share,
video_share_youtube.
But I don't know where I can find all these types? I need this types to create good design in HTML, for example when attachment type is video_share_youtube, I know this attachment is youtube movie. If type is "share" it's just pasted a url into text message. But I know that not all types of attachments.
Here is my code:
$response = file_get_contents("https://graph.facebook.com/$group_id/feed?fields=videos,from,picture,message,full_picture&limit=$limit&access_token=$token");
$response = file_get_contents("https://graph.facebook.com/$group_id/feed?fields=attachments,description,full_picture,picture,story,source,created_time,from,message&locale=pl_PL&limit=$limit&access_token=$token");
$array = json_decode($response, true);
Thanks.
The question is, what are the types you are interested in for your website, as the file types are vast. Basically, I did this.
Created a file with possible formats (.doc, .txt, .pdf, .jpeg etc.,), attach it to the message and observe response from graph api.
The most possible types from mime_type field are,
application/pdf
application/msword
text/plain
image/jpeg
image/gif
"data": [
{
"id": "abcd",
"mime_type": "text/plain",
"name": "Sample 1.txt",
"size": 12,
"file_url": ""
},
{
"id": "abcd",
"mime_type": "text/plain",
"name": "Sample2.txt",
"size": 12,
"file_url": ""
}
]

Can't post node that requires a pre assigned value with services api

I have setup a content type with a subject field that has pre assigned values in a dropdown field.
I am using the services api to post new content from a polymer app.
When I POST to the api I send the field structure and value in json but get and error.
"406 (Not Acceptable : An illegal choice has been detected. Please contact the site administrator.)"
Even though the object I am sending matches one of the required values in the field.
Do I need to prefix the value with something? I assume I'm posting to the right place to get that response but don't know why it would accept anything other than the string value.
Here is what I sent to the api which is picked up by my Charles proxy.
{
"node": {
"type": "case",
"title": "my case",
"language": "und",
"field_subject": {
"und": {
"0": {
"value": "subject1"
}
}
},
"body": {
"und": {
"0": {
"value": "my details of subject"
}
}
}
}
}
And here is an example of what I have setup in my Drupal field
subject1| first
subject2| second
subject3| third
subject4| forth
For anyone else with the same problem, this subject is poorly documented, but the answer is simple, my subject did not need the value key despite devel suggesting thats how it would be formatted.
"field_subject": {
"und": [
"subject1"
]
}
I could also shorten my code with "und" being an array.