Failing to send PM v3 via API v2 notes_threads collection
I am building an endpoint that should send a private message from the current admin user to a given user. I am using the restbuilder to build my CREATE call to the notes_threads collection like this:
<#assign PMPostCall = restBuilder()
.method("POST")
.path("/notes_threads")
.body({
"type": "notes_thread",
"subject" : "Important note",
"new_note" : {
"type" : "threaded_note",
"body" : "We have just approved your application. Welcome and now please take a look around."
},
"thread_recipients" : {
"list_item_type":"note_recipient",
"items": [
{
"type" : "note_recipient",
"user": {
"type": "user",
"login": "ClaudiusTest"
}
}
]
}
})
.admin(true) />
<#assign resp = PMPostCall.call() />
Looking at ${resp.message} I only get a not very helpful "New note couldn't be sent due to error null".
Can you spot anything wrong with my code? (The user "ClaudiusTest" does exist)
Anyone can share some code for sending PM v3 that works?
Hi Claudius,
I tried this out locally and found a bug that is causes a NullPointerException in the java back-end when you don't include the "is_broadcast" field. To work around this, just add the field, set to either true or false (the different options are discussed on the Threaded Private Message API Support page):
<#assign PMPostCall = restBuilder() .method("POST") .path("/notes_threads") .body({ "type": "notes_thread", "subject" : "Important note", "new_note" : { "type" : "threaded_note", "body" : "We have just approved your application. Welcome and now please take a look around." }, "is_broadcast": false, "thread_recipients" : { "list_item_type":"note_recipient", "items": [ { "type" : "note_recipient", "user": { "type": "user", "login": "admin" } } ] } }) .admin(true) /> <#assign resp = PMPostCall.call() />
I will file a bug to have this bug corrected.
Thanks,
-Doug