How to change ejabberd MUC subject - xmpp

I've tried to change MUC subject using ejabberd API but didn't work. I use Postman to work with the API
api : /api/change_room_option
request body :
{
"name": "testgroup",
"service": "conference.localhost",
"option": "subject",
"value": "BookNerds"
}
error : "400 Bad Request"
I've enabled change_room_option in my ejabberd.yaml and set allow_change_subj to true. Using this configuration and same request body format, I successfully change 'title' and 'description'.
Note : I ran another test using Adium and successfully change the subject. When I check in database, subject and subject_author have been updated. Do I need to set subject_author too in the request body? If yes - I don't think it's possible since change_room_option will only accept four parameters as stated here

Related

Is there a way to retrieve the generated HTML email body of a dynamic template via SendGrid API call?

We have a site where our agents enter in some data, and then that data is sent to a client, via a SendGrid dynamic template.
The email content includes a lot of calculations based on the data entered, so we want our agents to have the ability to preview the email and verify the content first before sending it to the client.
Is there a way to use the SendGrid API to send a request with our json object, but instead of sending the email to the client, receive the generated email body so that we can display it to the agent and let them review it first?
Answered my own question. API v3 has GET methods for Dynamic Transactional Templates and Template Versions.
API Call:
/templates/{template_id}/versions/{version_id}
using sendgrid-ruby:
sg = SendGrid::API.new(api_key: sendgrid_api_key)
sg.client.templates._(template_id).versions._(template_version_id).get
(Note: the template_version_id is the ID and not the Name of the template version)
The response body then includes a field called html_content which is the full rendered HTML of a dynamic template version with any handlebar templating.
You can make API call via postman as:
https://api.sendgrid.com/v3/templates/d-d44fdfsdfdsfd342342343
with Bearer token along with Sendgrid API key like:
Bearer SG.Fvsdfsdjfksdfsdfjsdkjfsdfksjdfsdfksjdfkjsdkfjsdf
The response is:
{
"id": "d-d55d081558a641b48a8a1145b4549fbe",
"name": "Bt_Payment_Reminder (Active)",
"generation": "dynamic",
"updated_at": "2021-12-21 07:35:12",
"versions": [
{
"id": "a95c3652-e49f-4608-a9dd-5aa4831c2dc3",
"user_id": 11702857,
"template_id": "d-d55d081558a641b48a8a1145b4549fbe",
"active": 1,
"name": "Bt_Payment_Reminder_Updated",
"html_content": "Hello {{firstName}}",
"plain_content": "Hello {{firstName}}",
"generate_plain_content": true,
"subject": "{{subject}}",
"updated_at": "2021-12-21 07:37:48",
"editor": "code",
"test_data": "{\n \"firstName\":\"Virendra\"}",
"thumbnail_url": "sdasdasdasdasdasdsd"
}
]
}

Request Sync giving a 404 error

I have followed this tutorial step by step
https://github.com/actions-on-google/actionssdk-smart-home-nodejs
but when I add a lamp or something it gives me this error:
POST REQUEST_SYNC https://homegraph.googleapis.com/v1/devices:requestSync?key=AIzaSyAB1Nxi3kLQzA5VDr0MgXJ32GDWJ4TA710
POST payload: {"method":"POST","headers":{"Content-Type":"application/json"},"body":"{\"agentUserId\":\"1234\"}"}
POST /smart-home-api/reset-devices 200 59.124 ms - 2
request-sync response 404 Not Found
Any ideas?
Followed this
https://developers.google.com/actions/identity/oauth2-assertion-flow
try creating a credential
Create a OAuth 2.0 (webapplication option) client IDs under console.cloud.google.com/apis/credentials
Plugged in the client id which looks like this ............apps.googleusercontent.com under GSI Client ID under console.actions.google.com/project/ ->overview->account linking->configure client->Checked all the check boxes (Not sure if i should) ->GSI Client ID
I had the same issue. In my case the problem was:
in the SYNC request, it requires to have an "agentUserId" parameter and it was missing.
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"agentUserId": "1836.15267389",
"devices": [{
https://developers.google.com/actions/smarthome/create-app
Make sure to send the same id when you send REQUEST_SYNC

OutLook Mail Rest API --> See if the message is a reply

I am trying to get a way to see if a message that i get using the Outlook Rest API using this url https://graph.microsoft.com/beta/me/messages('{messageid}') and seing if it is a reply. Normaly it would be from the Thread Id but the API doesn´t send one.
Is there anyway to see if the message is a reply?
API has one 'ConversationId' field. You can use that to group the messages.
{
...
"ConversationId": "AQQkADAwAT..."
...
}
This question has been answered here:
https://stackoverflow.com/a/60048538/3892957
Use GET https://graph.microsoft.com/v1.0/me/messages?$expand=SingleValueExtendedProperties($filter=(Id%20eq%20'Integer%200x1081'))
If a Message had been replied to you would see a result like
"singleValueExtendedProperties": [
{
"id": "Integer 0x1081",
"value": "102"
}
]

Facebook's Batch Request not picking up a JSON parameter

My goal is to create a number of ads using Facebook's Batch API : https://developers.facebook.com/docs/marketing-api/asyncrequests/v2.9
I am sending a POST request at this URL:
https://graph.facebook.com/v2.9/act_158365238/ads
I am sending 2 parameters as per the documentation:
1- access_token
2- batch
The JSON in the batch parameter looks like :
{
"method": "POST",
"relative_url": "v2.9\/act_158365238\/ads",
"attached_files": "test1",
"body": "creative={\"title\":\"Test title 1\",\"body\":\"Test body 1\",\"object_url\":\"https:\/\/apps.facebook.com\/testapp\/\", \"image_file\":\"test1.jpg\"}&targeting={\"countries\":[\"US\"]}&name=test1"
}
The Problem
When I send this request with POSTman or my PHP code, it throws the following error
{
"error": {
"message": "(#100) The parameter creative is required",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Gj2sG7N8l1f"
}
}
However when I send the exact same request via Facebook's Graph API tool, it successfully creates the ads.
According to the API Documentation provided to create creatives you should be posting to the URL "v2.9/act_187687683/adcreatives"... The fragment of the batch that you are showing is used to create an Ad.
If, as you say, your intention is to create an AdCreative then you should be using something like the above, which differs in the body from what you are using:
{
"method": "POST",
"name": "create_creative",
"relative_url": "v2.9/act_187687683/adcreatives",
"attached_files": "test1",
"body": "title=Test title&body=Test body&link_url=http://www.test12345.com&image_file=test1.jpg"
}
In the other hand, if what you are creating is an add, then you should consider referencing the AdCreative by its ID as is done in the examples, hence in the case of a creative added in the same batch you could use the relative reference to the name:
creative={\"creative_id\":\"{result=create_creative:$.id}\"}
or if it is a creative already created you can reference it by the creative_id:
creative={\"creative_id\":\"123456\"}
I think the message is a red herring -- it's not seeing your body's creative field because the OAuth isn't properly set in your POSTman requests, so it isn't parsing the body or seeing the creative field.
If you don't know how to set OAuth in POSTman, here's a good tutorial:
https://docs.brightcove.com/en/video-cloud/concepts/postman/postman.html

SendGrid API V3 returns 400 Bad Request

I am trying to achieve send of mail via SendGrid API.
Following is the JSON I am sending as a body of the POST Method
{
"content" : [
{
"type" : "text\/plain",
"value" : "Hello, World!"
}
],
"personalizations" : [
{
"to" : [
{
"email" : "sahpranav1712#gmail.com"
}
],
"subject" : "Hello, World!"
}
],
"from" : {
"email" : "iospranav1712#gmail.com"
}
}
and following is the return that I am getting
{"message":"Bad Request","field":null,"help":null}
This piece of info doesn't help much.
The authorization is in place, and I believe correctly.
Perhaps, I might have missed some sort of settings in the SendGrid App
If it helps im using Objective-C.
Please help!!
I experienced the same issue and the problem was actually that all substitutions in the personalizations field need to be string values (see https://github.com/sendgrid/sendgrid-php/issues/264)
"personalizations": [{
"to": [{
"email": "mail#gmail.com"
}],
"substitutions": {
"{myFloatVal}": 16.5,
"{firstname}": "Thomas"
}
}]
What exactly is a 400 BAD REQUEST?
Why you are getting 400 BAD REQUEST from SendGrid one can only guess. 400 BAD REQUEST means oh we probably know what happened we are just not telling you.
This is a common 'error handling technique' where the developer catches the error and simply returns false, hiding any of the details or reasons for the failure.
Check for duplicate addresses.
One possible reason, as was in my case, one of the CC addresses was also the TO address. You see among many other things, SendGrid does not allow an email address to occur more than once in a send request, and if you happen to list an email recipient more than once in any of the TO,CC, or BCC lists SendGrid just sends back 400 BAD REQUEST.
Other Reasons
There are dozens of other poorly documented reason for 400 BAD REQUEST and I sincerely wish you luck in finding out why SendGrid rejected yours. One of the other answers here may help you.
Not setting [manager setRequestSerializer:[AFJSONRequestSerializer serializer]];
was the issue!!!
My experience usually is that the body has to be without any new lines (\n or \r for example), otherwise it will return a 400 error. When I clear up any new lines, it works, I usually use something like:
reg_replace('/\s\s+/', ' ', $message)
While this is an old issue, the following might be helpful for others.
If you are using dynamic templates, make sure that the Id is correct. The dashboard does not lend itself to easy copying of the template id, which means that one can easily include an extra space in front of the id.
By adding a space (or any other character for that matter) to the id of the template, SendGrid will simply reply with a Bad Request, without letting you know why.
Check email list too. If there is null or empty string in your BCC or to list Sendgrid will throw BAD Request.