locked
HTTP/1.1 401 Unauthorized RRS feed

  • Question

  • Since a few days ago I am trying to connect to Microsoft Dynamics through soap and I always receive the same HTTP / 1.1 response 401 Unauthorized:

    To send the request, I first get the URL of the OAuth end. With this url and the application clientid and the secret key I get a token.

    The request is as follows:
    HTTP / 1.1 POST /XRMServices/2011/Organization.svc/web
    Host: xxxxxxxx.dynamics.com
    User-Agent: gSOAP / 2.8
    Content-Type: text / xml; Charset = utf-8
    Content-Length: 549
    Connection: close
    Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxltjhFJWwJgaYw
    "><? Xml version = "1.0" encoding = "UTF-8"?>
    Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
              
    ">Xmlns: xsd = "http://www.w3.org/2001/XMLSchema">
    "><Create xmlns = "http://schemas.microsoft.com/xrm/2011/Contracts/Services">
    "><Entity xsi: type = "Entity">
    account</LogicalName> "><LogicalName xmlns = "http://schemas.microsoft.com/xrm/2011/Contracts"> account </ LogicalName>
    "></ Create>
    "></ Envelope>


    And answer:
    HTTP / 1.1 401 Unauthorized
    Cache-Control: private
    Content-Type: text / html
    Server: Microsoft-IIS / 8.5
    REQ_ID: a9270c66-9c44-4962-a3a1-3f6dc0a1a56b
    Set-Cookie: ReqClientId = 003b3d8f-e7b6-4e9a-83c5-254c4ca5e42b; Expires = Tue, 22-Feb-2067 16:04:57 GMT; Path = /; Secure; HttpOnly
    WWW-Authenticate: Bearer redirect_uri = https% 3a% 2f% 2flogin.windows.net% 2fcommon% 2fwsfed, realm = Microsoft.CRM
    X-Powered-By: ASP.NET
    Date: Wed, 22 Feb 2017 16:04:56 GMT
    Connection: close
    Content-Length: 49
    Set-Cookie: crmf5cookie =! SnJWAFw16JBNWukNiJ9xy74dAil1tavAuyvms984cYRAKuaAn2wYzL2br0JTeZGL3sXHJPBNOl8vzEo =; secure; Path = /
    Strict-Transport-Security: max-age = 31536000; IncludeSubDomains

    HTTP Error 401 - Unauthorized: Access is denied


    What am I doing wrong? Thanks for the help
    Wednesday, February 22, 2017 4:14 PM

All replies

  • I have notice that when i get the access token, the expiredOn value is just my local time!!

    I live in Spain and my endpoint in https://xxxxx.api.crm4.dynamics.com/XRMServices/2011/Organization.svc/web.

    Any ideas??

    Thanks



    Thursday, February 23, 2017 11:46 AM