Zend_Uri_Http: Invalid URI supplied - even though url is valid - zend-framework

i have a url similar to this
http://one/two/three:four&five=six|seven
also i have
Zend_Uri_Http::setConfig(array('allow_unwise' => true));
in order to be able to use "|". when i try to use
Zend_Http_Client::setUri()
on my url, i get
Zend_Uri_Exception: Invalid URI supplied
when i hit the url from the browser, it works. how to avoid this problem. any ideas are welcome

The URL will be valid if you change it to:
http://one/two/three:four?five=six|seven
What is supposed to be the query string in that URI? You have to separate the query string from the path by ? before you can use & to separate arguments.

so it turns out i had a rewrite rule, defined in my httpd-vhosts.conf file, which created valid url after my invalid url was hit. since i needed to hit the url from within the zend framework phpunit test, i applied rewrite rule manually and got the correct url
moral of the story, put all the relevant info into your question, or else, nobody will be able to help you out

Related

Why doesn't the encoded 'slash' work as expected in restful api?

I have a restful api request like this:
http://0.0.0.0:4000/sentence=SUITS/Test。
And it gives an error in browser:
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
Then I URL encoded the 'SUITS/Test。':
http://0.0.0.0:4000/sentence=SUITS%2FTest
This give the same error message.
If I remove the '/' from URL, and it works fine.
Why doesn't URL encoding work here?
This is python restful api with flask_restful.
If you provide "/" before Test it would consider "Test" as a resource and then in this case "sentence" should be considered as query param passed as GET payload after "?" like:
http://0.0.0.0:4000/Test?sentence=SUITS

Why is GorillaMux not allowing me to pass in a URL as a parameter?

I'm building a URL shortener API and I'm trying to pass a URL into a function using GorillaMux. The route handler is like so:
router.HandleFunc("/new/{url}", createURL)
The only thing is, if I pass in: https://www.google.com (as in localhost:8080/new/https://www.google.com) then it responds with 404 page not found and the URL is changed to https:/www.google.com.
I've tried adding a regexp pattern in with the {url} bit like so: {url:[a-zA-Z0-9/]+} but that didn't seem to work and seems a bit overkill since I'm checking the url is correct elsewhere.
You need to encode it so that the slash in the parameter was not confused as a part of the url:
localhost:8080/new/https%3A%2F%2Fwww.google.com

how call REST service with path variable in webmethod?

I'm using WM9.8. I want to know how to call a GET REST service with path variable like:
http://localhost:8080/client/1 in webmethod.
I can call POST rest service using pub.client.http. But it dosen't work to GET.
Use String varible called "method" to set type of Http request method.
Just put the path variable in the URL and made a substitution to the path variable
e.g: http://localhost:8080/client/%yourPathVariableHere%
Holy cow this is an old question but I just tumbled across it and I thought I might helps somebody else who does.
URLs in webmethods are fixed to a single value, like /client unless you enable watt.server.url.alias.partialMatching=true
After that, you can simply alias a service to /client and all subURLs like /client/1 are sent to that service. You still have to parse them to get the ID out.
Be careful, though, because ALL sub URLs are sent to the service. So after enabling this flag I get /client, /client/1, /client/1/name all going to the same service. You can see how this can quickly become REST-unfriendly.

BigCommerce API Update Order with PUT

I need to update an order which is done via PUT method passing the order id as part of the https url string and a single parameter, the status_id.
https://mystore.mybigcommerce.com/orders/12345.json
I have tried several methods to pass the status_id value but no matter what I try "status_id=12" or formatted as JSON "{"status_id": 12,}" I always get the same response:
[{"status":415,"message":"The specified input content type is not valid."}]
I have also tried as a POST request passing the JSON or XML code as raw data but that method is not supported.
How am I supposed to pass that field=value pair? can I embed it in the url string?
I also tried it but it wouldn't work for me.
Any ideas?
In case you are wondering I am doing it within FileMaker with TROIUrl plugIn, not a very popular technology, but the GET method retrieving orders works like a charm
TURL_Put( ""; $url ;"status_id=12") (I have also tried other FM plugIns to no avail)
Don't get too caught up in the Filemaker part, I don't expect many people out there to be familiar with BigCommerce and Filemaker. I just need a generic answer.
Thanks
Commandline tool curl is worth a try. It supports put and https.
Mac OS X: curl already installed, call from FileMaker via AppleScript do shell script.
Windows: must be installed, call via Powershell.
It works for me using { "status_id": "3" } which means you probably need to put quotes around the actual number.
Also, it is a PUT operation and application/json which is part of the request content.
The error message received by the OP:
[{"status":415,"message":"The specified input content type is not valid."}]
Is saying that he did not supply the 'Content-Type' header in his request or that the header supplied is for a content type that is not allowed. For the OP's case using JSON he would need to include the header:
Content-Type: application/json
in his HTTPS request. This description can be found along with those of the other status codes you may see here:
https://developer.bigcommerce.com/api/status-codes

How to find the #fragment in a URL in Lift

I'm pretty new to Lift, and one of the things I've been trying to find is how to, in the context of a snippet, find the '#' in the current page's URL. So if a user visits http://www.example.com/some/path/page#stuff then I would like to extract "stuff" from that. I've been googling and searching the API docs and have yet to find anything for this.
I don't think the part behind the # ever gets sent to the server in the first place.
That's what wikipedia has to say about it:
In URIs a hashmark # introduces the
optional fragment near the end of the
URL. The generic RFC 3986 syntax for
URIs also allows an optional query
part introduced by a question mark ?.
In URIs with a query and a fragment
the fragment follows the query. Query
parts depend on the URI scheme and are
evaluated by the server — e.g., http:
supports queries unlike ftp:.
Fragments depend on the document MIME
type and are evaluated by the client
(Web-browser). Clients are not
supposed to send URI-fragments to
servers when they retrieve a document,
and without help from a local
application (see below) fragments do
not participate in HTTP redirections.
I don't think the part behind the #
ever gets sent to the server in the
first place.
You are correct, sir. That is the entire point of the hash.
Dylan, you could do something from the Javascript side:
$.ajax( { data : { fragment : window.location.hash ...