4

I am new to json i want get json data from a link, here from web search i have written code

    private void button1_Click(object sender, EventArgs e)
    {
        string url = @"http://hololens5.northeurope.cloudapp.azure.com/INTERSHOP/web/WFS/inSPIRED-inTRONICS_Business-Site/en_US/-/USD/ViewProduct-Start?SKU=1599925&CategoryName=151&CatalogID=Computers";
        using (WebClient wc=new WebClient())
        {
                json = wc.DownloadString(url);
        }

        string path = @"ouptputfileJSON.json";

        if (!File.Exists(path))
        {
            using (StreamWriter sw = File.CreateText(path))
            {
                sw.WriteLine(json);
            }
        }
    }

When i execute this code i'm getting output in html page. how to get in json data of select product in the link provided

2 Answers 2

1

Here is the rest endpoint you are looking for:

http://hololens5.northeurope.cloudapp.azure.com/INTERSHOP/rest/WFS/inSPIRED-
inTRONICS_Business-Site/-;loc=en_US;cur=USD/products/1599925

Documentation about other rest endpoints: https://support.intershop.com/kb/index.php/Display/T27711

Sign up to request clarification or add additional context in comments.

2 Comments

Hi @Willem Evertse, using above intershop links i have created ShoppingCart system in Unity following this format link. this Web Site link was running website. when i add product to cart its not showing cart in the website
i'm not sure i understand the question, but if u want to use the basket rest api of intershop you need to follow their flow, not create your own. See this support.intershop.com/kb/index.php/Display/260Q29 for details on how to integrate with intershop using the rest apis. If you have questions about intershop post using the intershop tag and the guys will help u out.
0

Because

http://hololens5.northeurope.cloudapp.azure.com/INTERSHOP/web/WFS/inSPIRED-inTRONICS_Business-Site/en_US/-/USD/ViewProduct-Start?SKU=1599925&CategoryName=151&CatalogID=Computers

Is webpage and not API endpoint so you need to find proper endpoint from where you want to get data

Once you get Proper Endpoint you can use below

Here is an example how you can use httpclient to make a request

static void Main()
{
    Task t = new Task(DownloadPageAsync);
    t.Start();
    Console.WriteLine("Downloading page...");
    Console.ReadLine();
}

static async void DownloadPageAsync()
{
    // ... Endpoint
    string page = "request URL";

    // ... Use HttpClient.
    using (HttpClient client = new HttpClient())
    using (HttpResponseMessage response = await client.GetAsync(page))
    using (HttpContent content = response.Content)
    {
        // ... Read the string.
        string result = await content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}

7 Comments

Sorry to say i am really starter as a developer so please tell me how could i find endpoint or how to create a Api endpoint
Is it your own website?
Here is the good tutorial for making web APIs in .net tutorialsteacher.com/webapi/test-web-api
You said that their is no proper end point, that means .html or .aspx or anything else should give there
when you make a get call to .aspx or .html page it'll always give you html data because that's what they are meant to do. on the other hand, API will give you JSON/XML or any other format, based on request and configuration because that's what they do. so you can't expect JSON from aspx or html
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.