Show TOC

Push API Notification ScenariosLocate this document in the navigation structure

The restnotification API allows to send message to multiple recipients in various scenarios.

Application
To send push notification to devices that are registered to an application, use:
  • On-Premise
    http[s]://<host:port>/restnotification/application/<applicationId>
  • Cloud
    https://<HMC base URL>/restnotification/application/<applicationId>
Request example body:
> POST /restnotification/application/123456789 HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 127
> {
 "alert": "alertval",
 "badge": 1,
 "data": "testData",
 "sound": "soundval"
}
< HTTP/1.1 201 Created
< Content-Length: 0
< Date: Mon, 05 May 2014 00:29:38 GMT
< Server: SAP

In this scenario, a status code 201 indicates that the server accepts the push notification request. Server forwards these requests to the external push service such as GCM, BES, BIS, APNS, WNS and so on. It does not indicate that the server has successfully delivered the notification to the devices.

Other possible HTTP status codes, you may encounter are:
  • 400 Bad Request: The request is invalid. Verify the request body.

  • 401 Forbidden: The user that issued the request does not have the required privileges. Ensure that the user is assigned to the "Notifcation User" role.

  • 403 Authentication required: No or incorrect credentials is provided. Enter the correct credentials.

Users and Devices
To send push notification to all the devices registered to a particular user, use:
  • On-Premise
    http[s]://<host:port>/restnotification/application/<applicationId>/user/<userID>
  • Cloud
    https://<HMC base URL>/restnotification/application/<applicationId>/user/<userID>
Request example body:
> POST /restnotification/application/123456789/user/timmitester HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 127
> {
 "alert": "alertval",
 "badge": 1,
 "data": "testData",
 "sound": "soundval"
}
< HTTP/1.1 201 Created
< Set-Cookie: X-SMP-SESSIDSSO=C05E58BE3CFC685ABB945D53C2AF14FD; Path=/; HttpOnly
< Set-Cookie: X-SMP-SESSID=4CC5BC2943E5D3A9B5D924888FC28CB060034F0092911A66B9F079047077798C; Path=/; HttpOnly
< Content-Length: 0
< Date: Mon, 05 May 2014 00:32:35 GMT
< Server: SAP
Registration ID
To send push notification to a device by using an application registration ID, use:
  • On-Premise
    http[s]://<host:port>/restnotification/registration/<applicationRegistrationId>
  • Cloud
    https://<HMC base URL>/restnotification/registration/<applicationRegistrationId>
Request example body:
> POST /restnotification/registration/9f847e51-3242-4899-9193-39b6e840d657 HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 127
> {
 "alert": "alertval",
 "badge": 1,
 "data": "testData",
 "sound": "soundval"
}
< HTTP/1.1 201 Created
< Set-Cookie: X-SMP-SESSIDSSO=D541E4898186AB304F506D13C0C3F1D0; Path=/; HttpOnly
< Set-Cookie: X-SMP-SESSID=FDB39F9BAE8A6E1AD4373765A58E094A14B8FDFB8289CC70E51B77A284C50736; Path=/; HttpOnly
< Content-Length: 0
< Date: Mon, 05 May 2014 00:36:15 GMT
< Server: SAP
Users per application
To send push notification to all the users of an application, use:
  • On-Premise
    http[s]://<host:port>/restnotification/application/<applicationId>/user
  • Cloud
    https://<HMC base URL>/restnotification/application/<applicationId>/user
Request body example:
POST /restnotification/application/123456789/user HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 277
> {
    "notification": {
        "alert": "alertval",
        "badge": 1,
        "data": "testData",
        "sound": "soundval"
    },
    "users": [
        "timmitester",
        "user1",
        "user2"
    ]
}
< HTTP/1.1 201 Created
< Set-Cookie: X-SMP-SESSIDSSO=9AD06173C8AB9FC05FD6AA8DC55BB9AE; Path=/; HttpOnly
< Set-Cookie: X-SMP-SESSID=DFB2D2AC4EBAA4903553EB7C5A0C90870BD4B8F3A3DC19A5FD984673EB1BD646; Path=/; HttpOnly
< Content-Length: 0
< Date: Mon, 05 May 2014 00:38:32 GMT
< Server: SAP
Registration list
To send push notifications to a list of registrations, use:
  • On-Premise
    http[s]://<host:port>/restnotification/registration
  • Cloud
    https://<HMC base URL>/restnotification/registration
Request body example:
POST /restnotification/registration HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 466
> {
    "notification": {
        "alert": "alertval",
        "badge": 1,
        "data": "testData",
        "sound": "soundval"
    },
    "registrations": [
        "3078e166-f144-4288-9dbc-1d192afe18d8",
        "9f847e51-3242-4899-9193-39b6e840d657",
        "4d1ccdf9-058a-42cf-a625-c4ed48944729",
        "f05dc905-b859-45fa-afdc-da3b630d2b48",
        "282be579-783e-40fb-b376-25bed5e13606"
    ]
}
< HTTP/1.1 201 Created
< Set-Cookie: X-SMP-SESSIDSSO=BCA5FCB41DD7F451410E3E8BB59E8F7A; Path=/; HttpOnly
< Set-Cookie: X-SMP-SESSID=2AC74022B258178ED3A88E4B2FA10AB41093F53C3D0A77976FE6FE076F1E3CC2; Path=/; HttpOnly
< Content-Length: 0
< Date: Mon, 05 May 2014 00:41:52 GMT
< Server: SAP
Customize Push Notification Types
Use customParameters to override the value for a particular notification type. Customize push notification types-alert, badge, data, and sound in the payload by prefixing with:
  • apns
  • bbbis
  • bbbes
  • gcm
  • mpns
  • wns
Example: Push to all users to the application with application ID "XYZ". Issue a POST method on:
> POST /restnotification/application/XYZ HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> {
 "alert": "alertval",
 "badge": 1,
 "data": "testData",
 "sound": "soundval"
}
Assume that some users have Android devices and the notification type parameter value must be reset. Use customParameters to override the value of the sound parameter:
> {
 "alert": "alertval",
 "badge": 1,
 "customParameters": {
   "gcm.sound": "soundforgcm"
 },
 "data": "testData",
 "sound": "soundval"
}