Hello,
Im trying to make azure services request work great in post man,
but i have pre request
"const sharedKeyName = “XXX”
const sharedKey = “XXX”
const uri = “Publicly Listed Services”
function createSharedAccessToken(uri, saName, saKey) {
if (!uri || !saName || !saKey) {
throw “Missing required parameter”;
}
var encoded = encodeURIComponent(uri);
var now = new Date();
var week = 606024*7;
var ttl = Math.round(now.getTime() / 1000) + week;
var signature = encoded + ‘\n’ + ttl;
const hash = CryptoJS.HmacSHA256(signature, saKey).toString(CryptoJS.enc.Base64)
return ‘SharedAccessSignature sr=’ + encoded + ‘&sig=’ +
encodeURIComponent(hash) + ‘&se=’ + ttl + ‘&skn=’ + saName;
}
// Set broker properties e.g. sessionId
const brokerProperties = {
‘SessionId’:‘123’
}
// Set broker proerties variable
pm.variables.set(“broker_properties”, JSON.stringify(brokerProperties));
// Set access token variable
pm.variables.set(‘access_token’, createSharedAccessToken(uri, sharedKeyName, sharedKey));"
I cant figure where to add this in HTTP request in UiPath,
we are using Sharedkey and key name to create access_token is this possible in UiPath?
using Azure.Messaging.ServiceBus;
using Azure.Identity;
// name of your Service Bus queue
// the client that owns the connection and can be used to create senders and receivers
ServiceBusClient client;
// the sender used to publish messages to the queue
ServiceBusSender sender;
// number of messages to be sent to the queue
const int numOfMessages = 3;
// The Service Bus client types are safe to cache and use as a singleton for the lifetime
// of the application, which is best practice when messages are being published or read
// regularly.
//
// Set the transport type to AmqpWebSockets so that the ServiceBusClient uses the port 443.
// If you use the default AmqpTcp, ensure that ports 5671 and 5672 are open.
var clientOptions = new ServiceBusClientOptions
{
TransportType = ServiceBusTransportType.AmqpWebSockets
};
//TODO: Replace the “” and “” placeholders.
client = new ServiceBusClient(
“.servicebus.windows.net”,
new DefaultAzureCredential(),
clientOptions);
sender = client.CreateSender(“”);
// create a batch
using ServiceBusMessageBatch messageBatch = await sender.CreateMessageBatchAsync();
for (int i = 1; i <= numOfMessages; i++)
{
// try adding a message to the batch
if (!messageBatch.TryAddMessage(new ServiceBusMessage($“Message {i}”)))
{
// if it is too large for the batch
throw new Exception($“The message {i} is too large to fit in the batch.”);
}
}
try
{
// Use the producer client to send the batch of messages to the Service Bus queue
await sender.SendMessagesAsync(messageBatch);
Console.WriteLine($“A batch of {numOfMessages} messages has been published to the queue.”);
}
finally
{
// Calling DisposeAsync on client types is required to ensure that network
// resources and other unmanaged objects are properly cleaned up.
await sender.DisposeAsync();
await client.DisposeAsync();
}
Console.WriteLine(“Press any key to end the application”);
Console.ReadKey();
In UiPath i get this error
The ‘await’ operator can only be used within an async method. Consider marking this method with the ‘async’ modifier and changing its return type to ‘Task’