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 :
Finance | Project Operations, Human Resources, ...
Unanswered

How to get web service with x++

(0) ShareShare
ReportReport
Posted on by

I need to call the interface URL as below.

http://devgw.OOOO.co.kr/approval/legacy/goFormLink.do?mode=DRAFT&logonId=220409&ERPworkkey=20220819094015&legacyFormID=WF_FORM_075&dataType=JSON

When i call that URL from a browser, the following 3rd party web page is popuped.

0456.fix.png

-my code is simple. 

Webresponse ended without any reaction from the area.

webresponse = webreq.GetResponse();

--- Job Class --

static void CreateWebAPI(Args _args)
{


System.Net.WebRequest webreq = System.Net.WebRequest::Create("">devgw.OOOO.co.kr/.../goFormLink.do

System.IO.Stream streamstr,responsestr;

System.IO.StreamWriter streamWriter;

System.Net.WebResponse webresponse;

System.IO.StreamReader reader;


webreq.set_Method("Get");

webreq.set_ContentType('application/Json');

// webreq.set_ContentType('application/x-www-form-urlencoded');

// streamstr = webreq.GetRequestStream();

// streamWriter = new System.IO.StreamWriter(streamstr);

//streamWriter.Write("CountryName=New+Zealand");

// streamWriter.Flush();

// streamWriter.Close();

// streamWriter.Dispose();

webresponse = webreq.GetResponse();

// responsestr = webresponse.GetResponseStream();

// reader = new System.IO.StreamReader(responsestr);

// info(reader.ReadToEnd());


}

I have the same question (0)
  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    First of all, let me re-post your code in the right way and throw away unused code. Next time, please use Insert > Code to paste source code to this forum.

    static void CreateWebAPI(Args _args)
    {
    	System.Net.WebRequest webreq = System.Net.WebRequest::Create(...):
    	System.Net.WebResponse webresponse;
    
    	webreq.set_Method("Get");
    	webreq.set_ContentType('application/Json');
    
    	webresponse = webreq.GetResponse();
    }

    My guess is that your code throws an exception, but you aren't aware of it, because you forgot to add exception handling. The key is catching CLRError. Then there are different ways how to extract informaton from the exception; let's use a simple one:

    static void createWebAPI(Args _args)
    {
    	System.Net.WebRequest webReq = System.Net.WebRequest::Create(...):
    	System.Net.WebResponse webResponse;
    
    	try
    	{
    		webReq.set_Method("Get");
    		webReq.set_ContentType('application/Json');
    
    		webResponse = webReq.GetResponse();
    	}
    	catch (Exception::CLRError)
    	{
    		throw error(AifUtil::getClrErrorMessage());
    	}
    }

    Run the code and you'll likely learn more about what happened.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans