Forum Discussion

patim's avatar
patim
Occasional Contributor
12 years ago

HELP! Unauthorized error for PUT method (REST web service))

Hi,

I want to test store API (REST web service) using PUT method.

Steps I followed:
1. Created project > REST service > Method > Request
2. PUT/entities/{entity-id}
Specify endpoints
I passed value for {entity-id}
Enter xml details in request editor
Specify authorization details in Authorization tab

3. but while running getting Unauthorized error

Cant figure-out why I am getting this as I am sure I have provided correct authorization details.

request log as follows:
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "PUT /entities/http://iddn.icis.com/fields/high HTTP/1.1[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "Accept-Encoding: gzip,deflate[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "Accept: application/vnd.icis.iddn.entity+xml[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "Content-Type: application/x-www-form-urlencoded[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "Content-Length: 0[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "Host: localhost:9100[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "Connection: Keep-Alive[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:>> "[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "HTTP/1.1 401 Unauthorized[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "WWW-Authenticate: Basic realm=public[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "Content-type: application/vnd.icis.iddn.error+xml[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "Server: MarkLogic[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "Content-Length: 233[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "Connection: Keep-Alive[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "Keep-Alive: timeout=1, max=96[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "[\r][\n]"
Thu Aug 30 14:39:28 BST 2012:DEBUG:<< "<e:error xmlns:e="http://iddn.icis.com/ns/errors"><e:code>ERRHANDLER002</e:code><e:http-code>401</e:http-code><e:http-status>Unauthorized</e:http-status><e:description>IDDN client user identity is not valid</e:description></e:error>[\n]"

Please help to fix this.

1 Reply

  • Bruiser's avatar
    Bruiser
    New Contributor
    Hello --

    Looking at the logs I see this line:

    WWW-Authenticate: Basic realm=public

    This indicates a BasicAuthentication requirement meaning you must present a user/password for the public realm in the request headers. The absence of these credentials would account for the unauthorized error message you are receiving.

    Hope this help.

    Peace.