Thursday, May 30, 2019

AX 2012 VAT HMRC integration error "HMRC service returned error code 406"

When we try to retrieve VAT obligations we will end up with an error "HMRC service returned error code 406".

We need to change the below code.

Add the below code in RetailCommonWebAPI class

        if (strLen(_request.parmAcceptEncoding()) > 0)
        {
            headers.Add(_request.parmAcceptEncoding());
        }

        if (strLen(_request.parmAccept()) > 0)
        {
            request.set_Accept(_request.parmAccept());
        }

and 
        this.initRequestClientCertificates(_request.parmClientCertificates(), request);





Tuesday, February 5, 2019

D365 F&O oData Post request Error "Cannot convert a value to target type 'Edm.Decimal' because of conflict between input format string/number and parameter 'IEEE754Compatible'"

Some times we will get the below error with oData post request to D365 F & O.
System.InvalidOperationException: Cannot convert a value to target type 'Edm.Decimal' because of conflict between input format string/number and parameter 'IEEE754Compatible' false/true. at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataEntityDeserializer.ReadODataBody[T](HttpRequestMessage request) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataEntityDeserializer.ReadODataBodyAsType(HttpRequestMessage request, Type clrType) at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataEntityDeserializer.ReadODataBodyAsDelta(HttpRequestMessage request, Type clrType) at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataController.ReadBodyAsDelta(EntityType entityType) at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataController.Post() at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayCl
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Solution is add to content type as "application/json;IEEE754Compatible=true"

Friday, January 11, 2019

HTTP Error 400. The request has an invalid header name - Post request to D 365 F&O oData service from Fiddler

An error "HTTP Error 400. The request has an invalid header name" comes when we do Post request to D 365 F&O oData service as below from Fiddler.

Request message:
POST https:axurl/data/XXX HTTP/1.1
Content-Type: application/json; charset=utf-8
Authorization: Bearer
Host: axurl
{
"@odata.type":"#Microsoft.Dynamics.DataEntities.XXX",
"dataAreaId":"YYY"
}

Error message:
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 11 Jan 2019 14:54:42 GMT
Connection: close
Content-Length: 339

Bad Request

Bad Request - Invalid Header



HTTP Error 400. The request has an invalid header name.



The solution to resolve this error is just add extra space between header and body as below

POST https:axurl/data/XXX HTTP/1.1
Content-Type: application/json; charset=utf-8
Authorization: Bearer
Host: axurl

{
"@odata.type":"#Microsoft.Dynamics.DataEntities.XXX",
"dataAreaId":"YYY"
}