BookmarkSubscribeRSS Feed
KK-321
Calcite | Level 5
 I'm trying to get a list of the file names in a directory (&path) from azure. The following code works well in an interactive SAS session but encountering a "400 Bad Request" error in batch mode. 
In the output.xml file, I get this message: <?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidAuthenticationInfo</Code><Message>Authentication information is not given in the correct format. Check the value of Authorization header.
Why the azure_token is not working in the batch mode? Can someone please give some possible solutions?

Here is the code:
 
filename json_in temp;
  data _null_;
    file in;
  run;

  filename resp "X:\output.xml";
  proc http
    method="GET"
    url= "&pathx.?restype=directory&include=timestamps&comp=list"
    in=in
    out=resp;
    headers
    "x-ms-file-extended-info" = "true"
    "x-ms-version" = "2022-11-02"
    "x-ms-file-request-intent" = "backup"
    "Authorization" = "Bearer &azure_token.";
  run;



7 REPLIES 7
ChrisNZ
Tourmaline | Level 20

I suspect the batch job runs under a different userid that can't access Azure.

KK-321
Calcite | Level 5

The SAS session and batch are run on the same machine. Is it possible they are under different user ids? Do you know where and how can I find this id?

ChrisNZ
Tourmaline | Level 20
Look how is the batch job is scheduled.

You can write &sysuserid to the log to see what user is used.
KK-321
Calcite | Level 5

In SAS session, the token looks ok, but in batch mode, the macro is not resolved because of 400 bad request. The log shows xxxxxx.

ballardw
Super User

I don't see a variable &path. I do see &pathx

 url= "&pathx.?restype=directory&include=timestamps&comp=list"

I also do not see where &path or &pathx is set. So without that bit of info I would say that is the likely problem: the macro variable with the path is not assigned, or assigned incorrectly in batch mode.

 

Where is the LOG created when you run this? I see several things that SAS might complain about as undefined macro variables that are URL elements.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1603 views
  • 0 likes
  • 4 in conversation