web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Running on server vs client commaIO.finalise()

(0) ShareShare
ReportReport
Posted on by

Hi there,

I have a link to a third party marketing system that I send sales information to each morning.  This has been going well until I tried to run it as a batch.  In it I create a commaIO file and then transfer the file using HTTPWebRequest / HttpWebResponse.  I have closed the commaIO file using commaIO.finalise() then called the method that does the http stuff.  When I run it from a client it all goes well and I get the response that it's uploaded correctly BUT if I run it through the batch I get a response 

System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Dynamics.Ax.Application.Methodusedtosend.xpp:line 79

Line 79 is the first line of the catch statement ex = CLRInterop::getLastException();

I know the batch server has access to the internet as I have another link that uses a URL service that works fine.  When I run this and save the commaIO file to disk instead of trying to send it to the HTTP it has data in the file.  But when running via the batch server the only thing in the file is the headings - which is why it returns the bad request - it needs at least one line.

I thought it might not be releasing the file but I thought the the commaIO.finalise() should close and flush to disk.

Any ideas would be much appreciated.

Kind Regards,

Paulina

  

*This post is locked for comments

I have the same question (0)
  • Jie G Profile Picture
    on at

    Hi Paulina,

    Please try to check the HTTP request to compare with the ones sending from a client.

    You may make use of Fiddler to look into it.

  • Community Member Profile Picture
    on at

    Thanks for looking at my query.  The requests are the same - the only difference is that the file when running on the server does not have any data other than the headings.  The request must have at least one line of data.  If I run via a client the commaIO file flushes to disk correctly.  I'm sure I've just missed a command somewhere that I get away with on a client but not when running via a server.

    Regards,

    Paulina

  • Verified answer
    Community Member Profile Picture
    on at

    OK found my own answer for those that are interested.  It was to do with the filepermission.  On the client it is ok to do the CodeAccessPermission::revertAssert(); after the finalise and before the HTTPWebRequest but on the server the file IO permissions are tighter and you need to do the HTTPWebRequest before you do the CodeAccessPermission::revertAssert();

    Thanks for looking

    Paulina

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans