Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Query value is passed correctly but does not return any results in the query API string

Query value is passed correctly but does not return any results in the query API string

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasecom
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hm9
    wrote on last edited by
    #1

    I have a form that submit a query to an API. the parameter is passed correctly to the next page and I can print it as a test, but it is not passed to the API query

    q='%"&Request.QueryString("id")&"%'

    sometimes the result is just generic and does not include the query parameter. I can print it and the parameter is definitely passed to the page but it is just ignored or return an error: System.NullReferenceException: Object reference not set to an instance of an object. Any ideas on how to fix this? not sure if it is a formatting issue or the way the page is loaded.

    This requests the query parameter and displays it on the page as a test (correct value is returned)

    Form page:

    dim intID as String
    intID = Request.QueryString("id")
    Response.write(intID)

    Result Page:

    This is the Query Parameter section:
    Dim doc As New XmlDocument()
    doc.Load("http://api.tradedoubler.com/1.0/products.xml; q='%"&Request.QueryString("id")&"%';tdCategoryId=168;%20category=test?token=B17495243749DAC9660980F6FB98495928DDX123")

    So when I use the browser - copy the link to the url with a parameter e.g. q=spain, I get the correct results but when embedded in the asp.net page, it doesn't work

    Richard DeemingR 1 Reply Last reply
    0
    • H hm9

      I have a form that submit a query to an API. the parameter is passed correctly to the next page and I can print it as a test, but it is not passed to the API query

      q='%"&Request.QueryString("id")&"%'

      sometimes the result is just generic and does not include the query parameter. I can print it and the parameter is definitely passed to the page but it is just ignored or return an error: System.NullReferenceException: Object reference not set to an instance of an object. Any ideas on how to fix this? not sure if it is a formatting issue or the way the page is loaded.

      This requests the query parameter and displays it on the page as a test (correct value is returned)

      Form page:

      dim intID as String
      intID = Request.QueryString("id")
      Response.write(intID)

      Result Page:

      This is the Query Parameter section:
      Dim doc As New XmlDocument()
      doc.Load("http://api.tradedoubler.com/1.0/products.xml; q='%"&Request.QueryString("id")&"%';tdCategoryId=168;%20category=test?token=B17495243749DAC9660980F6FB98495928DDX123")

      So when I use the browser - copy the link to the url with a parameter e.g. q=spain, I get the correct results but when embedded in the asp.net page, it doesn't work

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      hm9 wrote:

      http://api.tradedoubler.com/1.0/products.xml; q='%spain%';tdCategoryId=168;%20category=test?token=B17495243749DAC9660980F6FB98495928DDX123

      That doesn't look like a valid URL. Compare it to the working URL you're loading in the browser.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      H 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        hm9 wrote:

        http://api.tradedoubler.com/1.0/products.xml; q='%spain%';tdCategoryId=168;%20category=test?token=B17495243749DAC9660980F6FB98495928DDX123

        That doesn't look like a valid URL. Compare it to the working URL you're loading in the browser.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        H Offline
        H Offline
        hm9
        wrote on last edited by
        #3

        It is valid and works on the browser apart from the token which is modified

        J 1 Reply Last reply
        0
        • H hm9

          It is valid and works on the browser apart from the token which is modified

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          The Url could be valid, but Request.Querystring("q") can't find "Q" because the call just parses the Url for "/?" and "&" It can find it if the Url was shaped like this

          http://api.tradedoubler.com/1.0/products.xml?q=spain&c=seville

          Otherwise you would have to write some custom code to parse your Url the way you have it formatted.

          If it ain't broke don't fix it Discover my world at jkirkerx.com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups