U00045099 The server replied with following status: '401' in JCP log
search cancel

U00045099 The server replied with following status: '401' in JCP log

book

Article ID: 216131

calendar_today

Updated On:

Products

CA Automic One Automation

Issue/Introduction

In the JCP log you find the following error:

20210526/155108.345 - 58     U00045098 Method 'GET', URL: 'http://server.domain.example.com:8088/ae/api/v1/22/objects/MY_OBJECT', received from IP: '<IP address>'
20210526/155108.361 - 58     U00045099 The server replied with following status: '401'

When activating the JCP trace (Rest=9), you find the following error:

20210526/155108.345 - 58     U00045098 Method 'GET', URL: 'http://server.domain.example.com:8088/ae/api/v1/22/objects/MY_OBJECT', received from IP: '<IP address>'
20210526/155108.361 - 58               Request-Headers: [Host=server.domain.example.com:8088,User-Agent=Jakarta Commons-HttpClient/3.1]
20210526/155108.361 - 58               Request-Payload:
20210526/155108.361 - 58               
20210526/155108.361 - 58               Authentication Failed: Authorization header is missing
20210526/155108.361 - 58     U00045099 The server replied with following status: '401'
20210526/155108.361 - 58               Response-Headers: [Content-Type=application/json,WWW-Authenticate=Basic realm="AUTOMIC"]
20210526/155108.361 - 58               Response-Payload:
20210526/155108.361 - 58               {
20210526/155108.361 - 58                 "code" : 45229,
20210526/155108.361 - 58                 "error" : "Authorization header is missing.",
20210526/155108.361 - 58                 "details" : "No detail information available."
20210526/155108.361 - 58               }

When looking further in the trace you will see that the exact same request is received a second time, this time with the header included:

20210526/155108.439 - 49     U00045098 Method 'GET', URL: 'http://server.domain.example.com:8088/ae/api/v1/22/objects/MY_OBJECT', received from IP: '<IP address>'
20210526/155108.439 - 49               Request-Headers: [Authorization=Basic TVZFL01WRTpNVkU=,Host=server.domain.example.com:8088,User-Agent=Jakarta Commons-HttpClient/3.1]
20210526/155108.439 - 49               Request-Payload:
20210526/155108.439 - 49               
20210526/155109.283 - 49     U00045105 Log on of 'USERNAME' successful.

Environment

Automic Automation v12.2 / v12.3

JCP REST Endpoint

Cause

This expected behavior, see here:  https://en.wikipedia.org/wiki/Basic_access_authentication#Protocol

What happens is that by default the initial request is sent without header. The protocol then sends a 401 error back, upon which requester includes the header and sends the request again.

Resolution

In some case the error message can be prevented by preemptively sending the header. 

For instance in the case of the Automic REST Agent, you can tick the option 'Preemptive' in the REST Connection Object:

https://docs.automic.com/documentation/webhelp/english/AA/12.3/RA_WEB_SERVICE_REST/4.5/Agent%20Guide/help_en.htm#RA/WS/AWI/Creating_REST_Connection_Objects.htm