Pushes a notification to an endpoint by sending a POST request.

Description

You can call the MNS operation to push a notification to an endpoint by sending a POST request. Notifications support the following formats:

  • XML format

    The request body contains the message content and related parameters.

  • SIMPLIFIED format

    The request body contains only the message content. The ID of the message is included in the request headers.

Request

Each request consists of the following parts:

  • Request line

    POST /notifications HTTP/1.1

    By default, the /notifications section is specified in the request line. If you specify a URI for the endpoint when you create a subscription, you can replace /notifications with the URI.

  • Operation-specific URI parameters

    None.

  • Operation-specific request headers
    Parameter Description Supported content formats
    Authorization The signature of the request. XML and SIMPLIFIED
    x-mns-signing-cert-url The Base64 encoded URI of the signature certificate. XML and SIMPLIFIED
    x-mns-request-id The ID of the request. XML and SIMPLIFIED
    x-mns-message-id The ID of the message to be pushed. SIMPLIFIED
    x-mns-message-tag The tag of the message to be pushed. SIMPLIFIED
  • Request Body

    If you set the NotifyContentFormat parameter to XML, the request body includes the message content and the related parameters.

    Parameter Description
    TopicOwner The owner of the topic.
    TopicName The name of the topic.
    Subscriber The subscriber client.
    SubscriptionName The name of the subscription.
    MessageId The ID of the message.
    Message The message body.
    MessageMD5 The MD5 hash of the message body.
    MessageTag The tag that is used to filter messages.
    PublishTime The time when the message was published. The value is a timestamp that follows the UNIX time format. It is the number of milliseconds that have elapsed since 00:00:00 Thursday, January 1, 1970.

    If you set the NotifyContentFormat parameter to SIMPLIFIED, the request body contains only the message body.

Response

Each response consists of the following parts:

  • HTTP Status Code

    HTTP/1.1 204 No Content

    • If a notification is processed, the HTTP status code 204 is returned. If the HTTP status code 204 is not returned within 5 seconds, the request times out and message pushing retries.
    • If the signature in the request fails to be verified, the HTTP status code 403 is returned.
    • If other errors occur, the HTTP status code 500 is returned.
  • Operation-specific response headers

    None.

  • Response Body

    None.

Examples

Sample requests

  • XML format
        POST /notifications HTTP/1.1
        Host: example.com
        Date: Tue, 08 Dec 2015 06:42:00 GMT
        Content-Length: 300
        Content-Type: text/xml;charset=utf-8
        Content-MD5: OGQzNjAwYjIwMWFiMTliZDlhNzc4YjAwZjc5MGQ4****
        Authorization: QSNS+vn3IqJI4lOh4X/dxTv7Qebi/wrEaBJlzFFTc0hJVRUmrHLQo24ojBUETpz48+jrsjxMGPJTILDw752J****
        User-Agent: Aliyun Notification Service Agent
        x-mns-request-id: 56667BB81FD0E7D12000****
        x-mns-version: 2015-06-06
        x-mns-signing-cert-url: aHR0cDovL21uc3Rlc3Qub3NzLWNuLWhhbmd6aG91LmFsaXl1bmNzLmNvbS94NTA5X3B1YmxpY19jZXJ0aWZpY2F0ZS5w****
    
        <? xml version="1.0" encoding="utf-8"? >
        <Notification xlmns="http://mns.aliyuncs.com/doc/v1/">
            <TopicOwner>$TopicOwner</TopicOwner>
            <TopicName>$TopicName</TopicName>
            <Subscriber>$Subscriber</Subscriber>
            <SubscriptionName>$SubscriptionName</SubscriptionName>
            <MessageId>6CC4D900CA59A2CD-1-15180534A8F-20000****</MessageId>
            <Message>{1:"a", 2:"b"}</Message>
            <MessageMD5>F1E92841751D795AB325861034B5****</MessageMD5>
            <MessageTag>important</MessageTag>
            <PublishTime>1449556920975</MessagePublishTime>
        </Notification>
  • SIMPLIFIED format
        POST /notifications HTTP/1.1
        Host: example.com
        Date: Tue, 15 Dec 2015 09:12:46 GMT
        Content-Length: 487
        Content-Type: text/plain;charset=utf-8
        Content-MD5: NmY4Njk0MzlmNzg3NTFkMTJiN2M5OWE4ZmYzNTU4****
        Authorization: aXZIpRkRmIavmwceCyrPatB7SaEbOJdWpmFWYX3nFwtmaixK/M/3kl1njY0pgM7mrIB7NlBv5NfUZNkcIjlO****
        User-Agent: Aliyun Notification Service Agent
        x-mns-message-id: 6CC4D900CA59A2CD-1-15180534A8F-20000****
        x-mns-message-tag: important
        x-mns-request-id: 566FD963B2B71C44481F****
        x-mns-signing-cert-url: aHR0cDovL21uc3Rlc3Qub3NzLWNuLWhhbmd6aG91LmFsaXl1bmNzLmNvbS94NTA5X3B1YmxpY19jZXJ0aWZpY2F0ZS5w****
        x-mns-version: 2015-06-06
    
        {1:"a", 2:"b"}

Sample success responses

HTTP/1.1 204 No Content