Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8757281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:15:50+00:00 2026-06-13T14:15:50+00:00

I’m working with JSON for a while now, but this is a problem I

  • 0

I’m working with JSON for a while now, but this is a problem I can’t solve.

The program is written in C# and has a method called CreateWebRequest():

public void CreateWebRequest()
    {
        CurrentTime = DateTime.Now;
        target = link;
        request = WebRequest.Create(target) as HttpWebRequest;
        request.ContentType = "application/json; charset=utf-8";
        request.Method = "PUT";
        request.ServicePoint.Expect100Continue = false;
        string postData = jsonString;
        System.Console.WriteLine("POSTDATA: " + postData);
        StreamWriter requestWriter;
        using (requestWriter = new StreamWriter(request.GetRequestStream()))
        {
            requestWriter.Write(postData);
        }

    }

The other function to fetch the result is called: CreateWebResponse():

public void CreateWebResponse()
    {
        WebResponse response;

        string text;
        try
        {
            response = (HttpWebResponse)request.GetResponse();
        }

        catch (WebException e)
        {
            MessageBox.Show(e.Message);
            return;
        }

        using (var sr = new StreamReader(response.GetResponseStream()))
        {
            text = sr.ReadToEnd();
        }

        APIresult apiresult = JsonConvert.DeserializeObject<APIresult>(text); //Deserialize the text

    }

These functions work all fine, there is only one problem: the code does two requests.

When I put the same JSON in the RESTClient in mozilla FireFox the JSON works fine. It also works great when I’m only using CreateWebRequest(), but when I use both of the methods it seems the code creats a second request?

Is it possible to create only a response? Combine these two functions to one which creates directly an response?

I tried other solutions and put them just together, none of them seems to work. When I call for a response the code doesn’t work properly anymore and creates two requests.

Has anyone a solution?

Thanks in advance.

The JSON function I call has several if statements and work fine according to RESTClient in Firefox.
The code below shows the code which is called correct by RESTClient and twice by the C# code:

$sql = 'SELECT...';
        $result = $db->sql_query($sql);//search for member id.
        if($row = $db->sql_fetchrow($result)){//when found, the user has access.
            $member_id = $row['member_id'];
            $sql = 'SELECT ...';
            $result = $db->sql_query($sql);//search for last login today.
            if($row = $db->sql_fetchrow($result)){//if the user has logged in today update the row. 
                $row_check_in_timestamp = $row['check_in_timestamp'];
                $sql = 'UPDATE ...';//update the row with the check out timestamp
                $db->sql_query($sql);
                break;
            }else{//the user hasn't logged in yet today, log in.
                $start_session_array = array(
                    'club_id'   => (int)$club_id,
                    'member_id' => (int)$member_id,
                    'check_in_timestamp' => (int)time(),
                );
                $sql = 'INSERT ...';//check user in and add a new row in the database
                $db->sql_query($sql);
                break;
            }
        }else{
            break;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:15:51+00:00Added an answer on June 13, 2026 at 2:15 pm

    SOLVED: I’m sorry every one and thanks for all the responses, but I’ve found the problem. I had an older version as service running all the time and made the second JSON call.

    I’ve found it by logging on the server side the calls and blocked code which call the JSON in my own code to figure this out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
This could be a duplicate question, but I have no idea what search terms
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.