Yes, I checked those. I'm not familiar with the JSON tool for bulk uploading, and we don't use .NET language. I'll try the JSON GUI tool, but since we usually create Unix cron job to handle batch processing automatically, I still think using Perl.Yesterday I used ChatGPT to help generate Perl code for Auth Token. Below is the code generated and I slightly modified the variable names. I tested the code and got output similar to Javascript code. For example, my output looks like:
Current UTC Date: Tue, 25 Jun 2024 13:16:23 GMT
x-ms-date: Tue, 25 Jun 2024 13:16:23 GMT
token: type=master&ver=1.0&sig=v4flGat%2Bx%2BxAxv%2FpGSxYS3NxY%2Fw%3D
Is it possible to replace Pre-script in Postman using below Perl code to test if it works?
#/usr/bin/env perl
use strict;
use warnings;
use Time::Piece;
use MIME::Base64;
use Digest::HMAC_SHA1;
use URI::Escape;
my $date = gmtime->strftime('%a, %d %b %Y %H:%M:%S GMT');
my $token = get_authorization_token('GET', 'dbs', '', $date);
print "Current UTC Date: $date\n";
print "x-ms-date: $date\ntoken: $token\n";
# Function to generate authorization token
sub get_authorization_token {
my ($method, $resource_type, $resource_link, $date) = @_;
my $text = join("\n", $method, $resource_type, $resource_link, $date, "", "");
$text = lc($text);
my $master_key = $ENV{COSMOS_KEY};
my $key = decode_base64($master_key);
my $hmac = Digest::HMAC_SHA1->new($key);
$hmac->add($text);
my $signature = encode_base64($hmac->digest, "");
my $auth_token = "type=master&ver=1.0&sig=" . uri_escape($signature);
return $auth_token;
}