Push campaign
Push a previously saved campaign (created with Create campaign) to a set of devices.
The campaign must be in progress and its pushMode property must be set to manual (see Campaign format). Note that these conditions are compulsory to enable manual push for a campaign.
This command is particularly useful if you want to push different contents to your users and see how they respond to it. Unlike normal campaigns, campaigns for which the manual mode option has been enabled can be pushed multiple times to the same device.
Request
Method |
Request URI |
HTTP version |
---|---|---|
POST |
https://management.azure.com/subscriptions/{subscription-id}/resourcegroups/{resource-group-name}/providers/Microsoft.MobileEngagement/appcollections/{app-collection}/apps/{app-resource-name}/campaigns/{kind}/{id}/push?api-version=2014-12-01 |
HTTP/1.1 |
Authentication
See Authentication.
Request URI Path Parameters
Parameter |
Description |
---|---|
kind |
Kind of campaign. Valid values are: announcements, polls, dataPushes, and nativePushes. |
id |
Campaign identifier as returned by a call to Create campaign. You can get a list of campaigns by calling List campaigns. |
Query String Parameters
Parameter |
Description |
---|---|
api-version |
API version, the only supported value is 2014-12-01. |
Request Headers
The following table describes required and optional request headers.
Request Header |
Description |
---|---|
Authorization |
See Authentication. |
Content-Type |
application/json |
Accept (optional) |
Its recommended to pass */* or application/json to have JSON error responses. |
Request Body
A JSON object with the following properties:
Property |
Description |
---|---|
deviceIds |
Device identifiers to push as a JSON array of strings. Note that if you want to push the same campaign several times to the same device, you need to make several API calls. |
data (optional) |
JSON object, alternative campaign’s content to use instead of the referenced campaign. The JSON format is the described in Campaign format. All campaign’s properties can be overridden except for the following: name, manualPush, audience, startTime and timezone. endTime can be overridden while keeping original timezone parameter. The effect is to change the client side expiration of the received campaign for the specific devices. If your campaign is a poll, the provided data should contain the same number of questions and choices that the one you created with the Create campaign command. Please note that all the push messages created using this parameter will expire after 4 weeks at maximum (endTime property of the campaign will be used if lower than 4 weeks in the future). |
Response
A 200 status code is returned on success.
Response Status Codes
Code |
Description |
---|---|
200 |
OK, response body includes rejected devices. |
400 |
Can be caused by one of the following conditions:
Check response body for details. |
401 |
Authentication error. |
413 |
Can be caused by one of the following conditions:
|
For information about status codes, see Status and Error Codes.
Response Headers
Content-Type |
application/json |
Response Body
A JSON object containing the following properties if the request was successful.
Property |
Description |
---|---|
invalidDeviceIds |
A JSON array containing all identifiers that have been rejected. A device can be rejected for the following reasons:
Please note that if the request parameters are valid but all the specified devices are rejected, the status code |
Example
Push default campaign payload to 2 devices, 1 of them being invalid (i.e. 97fddfdf62a4f8816fe2d355806c787b):
POST /subscriptions/84211edf-7c40-4c47-b152-a6a7233843b7/resourcegroups/MobileEngagement/providers/Microsoft.MobileEngagement/appcollections/myAppCollection/apps/myApp-android/campaigns/announcements/1/push?api-version=2014-12-01 HTTP/1.1
Host: management.azure.com
Accept: */*
Content-Type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSIsImtpZCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiJodHRwczovL21hbmFnZW1lbnQuY29yZS53aW5kb3dzLm5ldC8iL
{
"deviceIds" : [ "ae7a1e59c25725f77c6a06219dd67044" , "97fddfdf62a4f8816fe2d355806c787b" ]
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"invalidDeviceIds" : [ "97fddfdf62a4f8816fe2d355806c787b" ]
}
Push a specific payload to 1 valid device:
POST /subscriptions/84211edf-7c40-4c47-b152-a6a7233843b7/resourcegroups/MobileEngagement/providers/Microsoft.MobileEngagement/appcollections/myAppCollection/apps/myApp-android/campaigns/announcements/1/push?api-version=2014-12-01 HTTP/1.1
Host: management.azure.com
Accept: */*
Content-Type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSIsImtpZCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiJodHRwczovL21hbmFnZW1lbnQuY29yZS53aW5kb3dzLm5ldC8iL
{
"deviceIds" : [ "4f56b6db7023558b1ce30068f64404c0" ],
"data" :
{
"notificationTitle" : "Your command number #123 has been shipped!",
"notificationMessage" : "Click to track it.",
"actionUrl" : "http://mysite.com/commands/123"
}
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"invalidDeviceIds" : []
}