AX 2012 Error "Object must implement IConvertable"

This is working for normal running but when i put this code in a batch then it shows an error “Object must implement IConvertable”. Please anybody help me solve this issue asap.

Attached below is my code-:

select firstOnly integrationAPISetup;

#define.ContentType('application/json')

destinationUrl      =               integrationAPISetup.BaseURL + apiTable.APIPath;
response            =               new System.Net.HttpWebResponse();
clro                =               null;

requestJson = @integrationAPISetup.ConnectionString;

try
{
    new InteropPermission(InteropKind::ClrInterop).assert();
    httpHeader      =               new System.Net.WebHeaderCollection();
    clro            =               System.Net.WebRequest::Create(destinationUrl);
    request         =               clro;
    utf8            =               System.Text.Encoding::get_UTF8();
    bytes           =               utf8.GetBytes(requestJson);

    clro.set_Method("POST");
    clro.set_Headers(httpHeader);
    request.set_ContentType(#ContentType);
    request.set_ContentLength(bytes.get_Length());

    requestStream   =               request.GetRequestStream();

    requestStream.Write(bytes, 0, bytes.get_Length());

    response        =               request.GetResponse();
    responseStream  =               response.GetResponseStream();
    streamReader    =               new System.IO.StreamReader(responseStream);
    responseJson    =               streamReader.ReadToEnd();
    responseData = RetailCommonWebAPI::getMapFromJsonString(responseJson);

   mapEnumerator = responseData.getEnumerator();
    while ( mapEnumerator.moveNext())
    {
    }

// responseData = RetailCommonWebAPI::getMapFromJsonString(responseJson);

this is working for normal running but when i put this code in a batch then it shows an error “Object must implement IConvertable”

It seems that an exception is thrown by some code called inside getMapFromJsonString() but you don’t know yet where. Use the debugger to find it out.

My guess is that it’s about execution in CIL, not about batch processing as such. Note that you can use CIL without batch (e.g. using SysOperation framework), which may help you to understand whether it’s something specific to batch processing and it can also simplify your testing.

I also suggest you simplify your test case by removing the dependency on the web service. Use hard-coded JSON for testing, which will again simplify things and it’ll allow others to execute your code and review the data.

Thank you so much for replying back.
CIL is working properly without throwing any error and normally this is running fine but when I try to put it in a Batch, it throws an error.

So, reading is not an issue.

How did you execute code in CIL without a batch and did you confirmed it really executed in CIL? If you use SysOperation, for example, whether it executes or depends also on configuration.

Also, don’t forget all the other things I mentioned and you haven’t reacted to.