Hi Everyone,
I have jus started writing a job in AX7.
Getting the below error while executing the job,
The calling thread must be STA, because many UI components require this.
Below is the code,
class CookiesJob
{
///
/// Runs the class with the specified arguments.
///
/// The specified arguments.
public static void main(Args _args)
{
System.Uri uri;
System.Net.CookieCollection cookies;
int cookieCount;
try
{
uri = new System.Uri(“https://some.sharepoint.com”);
cookies = Microsoft.Dynamics.AX.Framework.OfficeAddin.SharePoint.AuthenticationHelper::GetSharePointOnlineCookies(uri, true);
if (cookies)
{
cookieCount = cookies.get_Count();
}
}
catch (Exception::CLRError)
{
throw error(AifUtil::getClrErrorMessage());
}
}
}
Regards,
Madhan
AX 7 is a web application; using UI components makes no sense there.
Thanks for your reply Martin.
Could you please let me know how I can change the above code?
What are you trying to achieve by your code? What cookies do you expect to find on the AOS server in Azure?
Hi Martin,
The requirement is to import multiple documents from SharePoint to AX and each document will be attached to a record in AX. I did this functionality in AX 2012 R3. I will use the saved cookies to import the documents.
Now just started to upgrade the SharePoint integration in AX7. And stuck with the above error.
could you please share some documents for this SharePoint integration in AX7.
Regards,
Madhan
Is your SharePoint publicly available from Azure? If it is, call its web services (with authentication details). If it’s only accessible from your internal network, you’ll have to write and app that will push it to AX through web services.