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

  • SEARCH
  • Home
  • 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 4024766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:45:44+00:00 2026-05-20T10:45:44+00:00

Not sure what is going on. When I perform the following code… it runs

  • 0

Not sure what is going on. When I perform the following code… it runs fine… but it is producing an error. If I paste the following into my browser address bar and hit it, I get one URL. If I put the same url through the KRL http:get, I get a completely different URL.

“http://tinyurl.com/api-create.php?url=http://insideaf.blogspot.com”

on my own in the browser I get: http://tinyurl.com/6j7qucx

when run through http:get I get: http://tinyurl.com/4fdtnoo

The difference is that the second one, the one run through the KRL http:get hits the requested site, but it appends a “/&” to the end of the request. It does this no matter what site I am on. If I am on http://www.google.com, it returns a tinyurl that results in http://www.google.com/& with gives me an error. All sites that I pass to the http:get method get returned with an & at the end. Here is my code, so that you can see that I am not accidentally adding it myself.

myLocation = event:param(“location”);

url2tiny = “http://tinyurl.com/api-create.php?url=”+myLocation;

tinyresponse = http:get(url2tiny);

tinyurl = tinyurl.pick(“$.content”);

If I console.log the url2tiny, it looks exactly like it should. It appears that when I pass url2tiny to http:get, it is automatically adding the & to the end of it before it requests it from the tinyurl api.

Any ideas for workarounds to this issue? It appears to be a bug in the http:get method. If I am wrong (and I hope I am), please point me in the right direction.

  • 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-05-20T10:45:45+00:00Added an answer on May 20, 2026 at 10:45 am

    In both cases, your format is just slightly off. http:get can be used as an expression in the pre block, but the syntax is different from the way that you use it in the action block.

    There are actually a number of different ways that you could make this request. The traditional way is through a datasource

    DATASOURCE

      global {
        datasource tiny_url_request <- "http://tinyurl.com/api-create.php";
      }
    
      rule using_datasource is active {
        select when pageview ".*" setting ()
        pre {
          myLocation = page:env("caller");
          thisTiny = datasource:tiny_url_request("?url="+myLocation);
        } 
        {
          notify("URL", myLocation) with sticky = true;
          notify("datasource: ", thisTiny) with sticky = true;
        }
      }
    

    The other way is how you were trying and it is through http:get as an expression in the pre block. Called as a function, http:get has 2 required parameters and two optional parameters:

    http:get(url, params, headers, response_headers );

    Your first attempt did not include the params.
    tinyresponse = http:get(url2tiny)

    The second attempt places the params in the wrong argument position.
    http:get(“tinyurl.com/api-create.php”;,{“url”:myurl})

    http:get (pre block)

      rule get_in_pre is active {
        select when pageview ".*" setting ()
        pre {   
          myLocation = page:env("caller");
          tinyurl = http:get("http://tinyurl.com/api-create.php", {"url":myLocation});
          turl = tinyurl.pick("$.content");
        }
        {
          notify("http:get as expression",turl) with sticky = true;
        }
    
      }
    

    The third method is using http:get as an action and auto-raising an event

    http:get (action)

      rule using_action is active {
        select when pageview ".*" setting ()
        pre {
          myLocation = page:env("caller");
        }
        http:get("http://tinyurl.com/api-create.php") setting (resp)
          with 
            params = {"url" : myLocation} and 
            autoraise = "turl_event";
      }
    
      rule get_event is active {
        select when http get label "turl_event" status_code "(\d+)" setting (code)
        pre {
          a = event:param("content");
        }
        notify("Autoraised from action",a) with sticky = true;
      }
    

    Here is an example of these rules executing against this very page
    enter image description here

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

Sidebar

Related Questions

Not sure what exactly is going on here, but seems like in .NET 1.1
I'm not too sure what is going on here, but sometimes a particular file
Not sure what's going on here. I have a DateTime object, and when I
Not sure how to ask a followup on SO, but this is in reference
Not sure if the title is quite right for the question but I can't
Not sure if anyone listened to Hanselminutes episodes 134 and 135, but at the
Not sure this is a programming question, but we use LaTeX for all our
Not sure if this is possible or if I'm expressing correctly what I'm looking
Not sure if this is intended behavior or a bug or a wrong function
Not sure exactly how to word this question ... so edits are welcomed! Anyway

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.