Azure Notification Hub: The supplied notification payload is invalid - azure

I'm trying to send a JSON notification to APNS and when I try to send it I'm getting 400 Bad Request with the error message:
The supplied notification payload is invalid.
Here is my Notification JSON:
{"uri":"myApp://test","type":"test_push","badge":1,"content-available":1}
I create the notification like this:
notif = new AppleNotification(json);
I'm sending the notification:
client.SendNotificationAsync(notif, "myTag")
After that, I'm getting the error. The content type is application/xml by default, after I got the error, I've started setting the content type to application/json but nothing changed.
What am I doing wrong?
UPDATE: My hub and certificates are installed correctly; I can send a successful test notification through Azure Portal.

Can,
Your payload is malformed, please try with the following:
{"aps":{"uri":"myApp://test","type":"test_push","badge":1,"content-available":1}}

After playing with the test push sending on Azure Portal, I've discovered the problem myself: Notification Hub wasn't accepting the JSON if it wasn't already wrapped in aps object. I've changed the JSON to be sent as:
{aps: {"uri":"myApp://test","type":"test_push","badge":1,"content-available":1} }
and now it's working. I thought it was auto wrapping, but apparently it isn't.

You can escape special characters using \. See in example below I have used double quote for word Hub which escape using \.
{"aps":{"alert":"Notification \\\"Hub\\\" test notification"}}

Related

DocuSign website cant call webhook listener

I try to receive signed file from Docusing using web hook listener, before it working file , but form 31-05-2022 Docusing cant call our web hook listener.
When i check log from Connect menu, i got this error on bottom
6/22/2022 | 3:52:07 pm
Error: Exception in EnvelopeIntegration.RunIntegration: ac08432f-18c4-471d-8720-caaf78fe4dfc :: No URI :: Error - Invalid URI: The URI is empty.;
This is the code i pass web hook listener url.
Dim eventNotification = New EventNotification()
eveventNotification.Url ="https://www.sample.com/webhook/default.aspx"
eventNotification.RequireAcknowledgment = "true"
eventNotification.IncludeDocuments = "true"
eventNotification.LoggingEnabled = "true"
May i know exact problem ? This final success receive from web listener is 5/30/2022, after that all are failure.
Thanks and Regards
Aravind
This error typically means you're using envelope-level EventNotifications, but you're not actually defining a valid url parameter when you're sending an envelope.
You'll want to check your Envelope Definition in your code, but you can also use API Request Logging to capture what your application is sending to DocuSign

Is it possible to use the Azure URL Ping Test to test whether a Direct Line Bot is alive?

I have a Web App Bot running on Azure.
It's using the Microsoft Bot Framework Direct Line API 3.0.
I want to use the URL Ping Test type instead of the Multi-Stage Web Test for the Availability Test of the Bot because I do not have the Visual Studio 2017 Enterprise edition.
In the Bot's message controller, this is how I handle the response for Pings.
I am able to get expected response in the Bot emulator when running the Bot in localhost.
else if (message.Type == ActivityTypes.Ping)
{
ConnectorClient client = new ConnectorClient(new Uri(message.ServiceUrl));
var reply = message.CreateReply();
reply.Text = "{Some message}";
await client.Conversations.ReplyToActivityAsync(reply);
}
However, when I connect to the Bot in Azure, I am getting HTTP error 500.
I'm not sure what is the root cause and wonder whether it is due to the URL Ping Test does not know the Direct Line secret.
Appreciate your kind help on this.
Thanks very much.
If you check the “Send an activity to the bot” in Direct Line API 3.0 documentation, you can find:
To send an activity to the bot, the client must create an Activity object to define the activity and then issue a POST request, specifying the Activity object in the body of the request.
URL ping test would sned a GET request to the URL that you specified, it would not hit/trigger the code that you defined for Ping activity in your MessagesController.
If you’d like to detect whether your bot is alive by sending a Ping activity, you could make a request like below from your client.
Request:
POST https://directline.botframework.com/v3/directline/conversations/{conversationId}/activities
Authorization: Bearer {directline_secret}
Content-Type: application/json
Body:
{
"type": "ping",
"from": {
"id": "user1"
}
}

The security token format does not conform to expected schema

I get the following response on Postman when making a GET request on
https://www.docusign.net/restapi/v2/accounts/{myclientidhere}/
The demo account integrator key was certified and moved to prod. I made the request in exactly the same way I did for the demo account using the new username, password and the integrator key details in prod. What could be going wrong here?
<errorDetails xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<errorCode>INVALID_TOKEN_FORMAT</errorCode>
<message>The security token format does not conform to expected schema.</message>
</errorDetails>
Edit:
As suggested by DocuSign, am using na2 as our production account is residing in the na2 environment
My request follows:
GET
Endpoint
https://na2.docusign.net/restapi/v2/login_information
Headers
Content-Type: application/json
X-DocuSign-Authentication: {"Username":"x#x.com","Password":"xxxx","IntegratorKey":"xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"}
Have downloaded the request logs but the list of logs all return 200 OK except the one looking for a profile image which I do not have so makes sense to receive a 404 not found as there is no image to link to. I don't see any other issues.
After working with the customer in the end we found the issue here was that they had the backslash (\) character in their password, which was being parsed as an escape sequence.
So basically the password was like:
a1b2#cd\%34
and the backslash was causing the error.
Just ran across the same problem. Apparently the " character is also disallowed in the password. Changed the password to exclude it and it now works fine.

Logic App Send Message error with JSON

I'm using Logic App to send a message to a service bus on Azure. The logic app starts with a HTTP Request for the trigger which contains a JSON payload in the body. The 'Body' of the request is set as the Content of the Send Message action. Since the payload is JSON when posting I set the Content-Type to application/json. This generates an error on the Send Message action;
{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'Send_message.' inputs at line '1' and column '1221': 'The template language function 'encodeBase64' expects its parameter to be a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#encodeBase64 for usage details.'."}
So tried changing the Content-Type to text/plain and it works? Is this a bug or should convert the JSON to a text value somehow before using it in the Send Message action?
Sending a message to service bus requires the message content to be base64 encoded. Since your content is a JSON, you would need to stringify it explicitly prior to encoding, i.e. use #encodeBase64(string(jsonContent))
Changing the content type to text/plain has the same effect, since in that case the content is treated as a string to begin with.

Where is the host and port coming from when I am reading Direct Line API doc from Microsoft Bot Framework

I noticed the Direct Line request url is like this: https://localhost:8011/api/ in the documention. What should replace it with?
I have deployed a todoBot example project from botbuilder Examples folder. And I have created a bot in My bots section, the ending point is: http://www.bigluntan.com:3978/api/messages. I have tested in Test connection to your bot section, it is working when I type something and send it. Right now, I want to give Direct Line a try. So I added Direct Line to Channels. But the most confused part is, how do I call this Direct Line api, cause the ending point is different than my bot's ending point.
The base URL is https://directline.botframework.com, so for instance, the POST request to get a new conversationId should be https://directline.botframework.com/api/conversations/
The request headers should include the Content-Type and also the following:
Authorization: BotConnector < Your secret >
where your secret is the code which was created when you created a Direct Line channel for your registered Bot (see image below). e.g.
Content-Type: application/json; charset=utf-8
Authorization: BotConnector pB7INWcXQjA.cwA.RF4.cglOUNHUOzWVv0Rlk3ovFNhtp1JPz1Zx9jmu8vX7zXs
Once you get a conversationId, you can POST a message using the URL https://directline.botframework.com/api/conversations/< conversationId >/messages
The body of the request should include the message text. You will not get the reply in the POST response. Instead, you need to get it by sending a GET to
https://directline.botframework.com/api/conversations/< conversationId >/messages. From there, you can get the "from" value in your first message, and use it in subsequent calls to the same conversation (otherwise the bot will not recognise the state, and just keep repeating the first reply message), e.g.
{
text: "yes",
from: "EQxvIzZOspA"
}
I found this out by trial and error. If you want to use the direct line api you should try https://directline.botframework.com
as the base URL

Resources