0

I am currently trying to make a dummy console app, to understand how AX web API works.

I added my odata webservice as a connected service, and from there not sure how i reference it in my main or make any get, calls to the service.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using Microsoft.Data.OData;
using System.IO;
using System.Xml;
namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://10.51.32.14:8101/DynamicsAx/Services/ODataQueryService/Invent");
            request.Method = "GET";
            request.ContentType = "application/x-www-form-urlencoded";
            //request.UseDefaultCredentials = true;
            //request.PreAuthenticate = true;
            request.Credentials = new NetworkCredential("admin_nc_keer", "C^Reup-rK)EH1j");
            //request.Credentials = CredentialCache.DefaultCredentials;
            try
            {
                using (WebResponse response = request.GetResponse())
                {
                    using (Stream stream = response.GetResponseStream())
                    {
                        XmlTextReader reader = new XmlTextReader(stream);
                        Console.WriteLine(" {0}={1}", reader.Name, reader.Value);
                    }
                }
            }
            catch(WebException e)
            {
                if (e.Status == WebExceptionStatus.Timeout)
                {
                    Console.WriteLine("Timeout!");
                }
                else throw;
            }
            Console.WriteLine("End!");
            Console.ReadLine();
        }
    }
}

Which returns nothing...

There is no container týpe defined for the odata data, but an contenttype, being

<content type="application/xml">
famle
  • 471
  • 2
  • 6
  • 10

0 Answers0