Question about the message ID when sending service bus messages using REST API?

Sheimaa Al-Awady 25 Reputation points
2023-12-18T18:30:57.7766667+00:00

I am using REST API to send service messages to my client. I sent the message ID as part of the request header, and I received 201, which means the message was created successfully.

However, the client is not receiving the message I sent. And they are asking me for evidence that the message was sent successfully. Basically, they are asking us to provide the message ID we receive from Microsoft once the message is created.

I didn’t receive an ID in the response. Will Microsoft use the same message ID I sent as part of the header? Or will they have a different ID?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
704 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2023-12-18T21:35:06.22+00:00

    Sheimaa Al-Awady Thanks for posting your question in Microsoft Q&A. Based on the description above, it seems that you are using Send Message Rest API to send message to Service Bus.

    MessageId they refer is part of BrokeredProperties and needs to be set on the client application side when sending the message (i.e. Azure Service Bus does not generate a unique message ID for each message sent.). Refer to https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messages-payloads doc for more info (or ServiceBusMessage.MessageId Property) and make sure to set the property as described.

    User's image

    If in case you use any library in your client application, refer language specific doc for guidance.

    I hope this helps and let me know if you have any questions.


    If you found the answer to your question helpful, please take a moment to mark it as Yes for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.

    2 people found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. JananiRamesh-MSFT 29,276 Reputation points
    2023-12-21T17:06:34.6633333+00:00

    @Sheimaa Al-Awady Thanks for reaching out. When you send a message to Azure Service Bus using REST API, you can set the MessageId property in the message header to a unique value that identifies the message. If you set the MessageId property in the request header, Azure Service Bus will use that value as the MessageId property of the message.

    However, the fact that you received a 201 response code from Azure Service Bus does not guarantee that the message was delivered successfully to the client. The 201 response code only indicates that the message was created successfully on the Azure Service Bus server.

    If the client is not receiving the message, there could be several reasons for this. If the message was delivered successfully, you should be able to retrieve it using the MessageId property.

    If you did not set the MessageId property in the request header, Azure Service Bus will generate a unique MessageId for the message. In this case, you can retrieve the message using the MessageId that was generated by Azure Service Bus.

    You can make use of Servicebus explorer to view the messages in the queue. https://github.com/paolosalvatori/ServiceBusExplorer/releases

    User's image

    do let me know incase of further queries, I would be happy to assist you.

    1 person found this answer helpful.
    0 comments No comments

  2. Sheimaa Al-awady 0 Reputation points
    2024-01-04T21:51:31.59+00:00

    Thank you for your answer. Yes, we do set the message id in the header. This issue happens intermittently. I will ask my client to open a Microsoft ticket if they experience the issue again.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.