This is regarding Azure Event hub and I am trying to send data using a POST api call from POSTMAN to my Event hub.
Steps I followed:
Created Event Hub, Generated SAS send token, Created Consumer group
Now in postman I am struggling to format the correct headers:
request I send:
POST: https://testeventhu.servicebus.windows.net/myhub
2 headers :
Content-Type : application/atom+xml;type=entry;charset=utf-8
Authorization: SharedAccessSignature sig=kjheh/f6SqR8dIW2nRpGUCHuhdshss2KoCKo7Q6ozmY=&se=1571140739&skn=saspolicy&sr=https://testeventhu.servicebus.windows.net/myhub
and I get the error as 401 MalformedToken: Failed to parse simple web token
What wrong am I doing in here?the refrence used is from https://learn.microsoft.com/en-us/rest/api/eventhub/Send-event?redirectedfrom=MSDN
Thanks in advance
Please follow my steps as below:
1.After you create your eventhub namesapce
and eventhub
instance in azure portal -> in azure portal, nav to your eventhub namespace
-> Shared access policies, click "Add" button to create a sas policy(here, I just select the Send privilege for sending purpose). The screenshot as below:
2.Generate sas token, I create the sas token via powershell as per this link. Here is my powershell code and the returned sas token:
3.In postman:
The request url should like this, remember add messages
at the end: https://your_eventhub_namespace.servicebus.windows.net/your_eventhub_instance/messages
The headers:
Authorization : the sas token from step 2
Content-Type: application/atom+xml;type=entry;charset=utf-8
Host(optional): your-eventhub-namespace.servicebus.windows.net
the screenshot as below, you can see the returned status code is 201 created:
And if you don't know how to set the message body, you can see my message in body in postman:
Please feel free to let me know if you still have any issues.