This question already has answers here:
How to escape a JSON string to have it in a URL?
(6 answers)
Closed 6 years ago.
I need to pass the following URL:
https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectFilter={"virtualGuests":{"hostname":{"operation":"hostnameTest"}}}
I tried by different ways, but it doesn't work, this is part of my code:
System.out.println(
given().
when().get("https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectFilter={\"virtualGuests\":{\"hostname\":{\"operation\":\"hostnameTest\"}}}").asString());
}
Exception:
java.lang.IllegalArgumentException: Invalid number of path parameters. Expected 1, was 0. Undefined path parameters are: "virtualGuests":{"hostname":{"operation":"hostnameTest".
According to the exception, I think I should need to use path parameters, I tried with that but I didn't have success.
Also, I tried to replace { with character escape code %7B.
Any ideas? Thanks in advance
I just tried this:
encodeURI('{"virtualGuests":{"hostname":{"operation":"hostnameTest"}}}')
And it gives me:
"%7B%22virtualGuests%22:%7B%22hostname%22:%7B%22operation%22:%22hostnameTest%22%7D%7D%7D"
Thanks a lot Sebastian and Robert!
I didn't have success using the encodeURI, however I used queryParam and it works
given().
queryParam("objectFilter", "{\"virtualGuests\":{\"hostname\":{\"operation\":\"hostnameTest\"}}}").
when().get("/SoftLayer_Account/getVirtualGuests")
.then().assertThat().body("id", hasItem(1111111));
Many Thanks!
Related
I'm just asking a question on finding error details from the error function.
Like I would like to find error details from example.lua:50: "then" expected near "if".
Any ways on how to do that on Lua? I'm working on something for ComputerCraft on Lua. (Minecraft Java mod)
EDIT:
I'm trying make a function that returns the error parsed out. It's supposed to return 3 variables, var1: file name, var2: line number (if none it is specified nil), var3: error text.
example.lua is the file where the error is. 50 is the line number. There is a syntax error, likely in the if condition. (I'm not familiar with ComputerCraft, so I don't know where that file might be.)
I am struggling with this issue:
InvalidArgumentException: The URI '' is invalid.
You must use a valid URI scheme. in Drupal\Core\Url::fromUri()
(line 284 of core/lib/Drupal/Core/Url.php).
How can I fix this?
You are passing a blank uri into the method. It is complaining about missing a scheme (eg. http:// or https://, or an internal scheme eg: internal:/)
So either you are explicitly passing a blank, or something isn't being set correctly. However, it does not seem to be null.
I had similar issue in Drupal 8 site, please make sure your files directory path is set correctly
I my case files path was Private and it was not configured in settings.php.
$settings['file_private_path'] = 'sites/default/files/private';
From the looks of the source code for the fromUri() function it would appear as though it throws that error when the PHP parse_url function returns an empty scheme:
... elseif (empty($uri_parts['scheme'])) { throw new \InvalidArgumentException("The URI '$uri' is invalid. You must use a valid URI scheme."); ...
From what I can gather in your question you seem to be providing an empty/null value to the fromUri method which is in turn causing the script to error when it attempts to parse the value. So I'd imagine that you'd need to do some kind of check before passing it to the fromUri function.
An example of how to use this method is helpfully provided in the comments section of the fromUri page: https://api.drupal.org/comment/61905#comment-61905
In case your URI is public://, then use:
\Drupal::service('file_url_generator')->generate($file->getFileUri())
can you help me to convert this to python 3.5 ? I tried but it don't work. I did the following steps:
I change the package md5 to hashlib
I change all the id = md5.new("%s"%str(clf.get_params())).hexdigest() to id = hashlib.md5(("%s"%str(clf.get_params())).encode('utf-8') ).hexdigest()
but I still have somme problems when I put a directory to these parameters
save_preds="",
save_params=""
save_test_only=""
clf_name="XX"
I have the folowing error when I put something in thise parameters:
TypeError: a bytes-like object is required, not 'str'
Please see the code here:
blend_proba.py
Thanks,
cdk
Replacing
clf_name="XX"
by
clf_name=b"XX"
would convert the strings into objects of type bytes. Whether those changes will be enough, I honestly have no idea.
This is the code snippet at line 461 which is giving badarg error ,please help me solve this error guys.
ejabberd_odbc:escape(base64:encode(crypto:aes_cfb_128_encrypt(<<"abcdefghabcdefgh">>, <<"12345678abcdefgh">>, xml:element_to_binary(NewPacket)))),
Log:
bad argument in call to crypto:aes_cfb_128_crypt(<<"abcdefghabcdefgh">>, <<"12345678abcdefgh">>, <<">, true) in mod_offline:'-store_offline_msg/6-fun-2-'/2 line 225
One of the things I like about functional languages is that you generally have an easier time reproducing errors in a controlled environment. In your case, it seems like
base64:decode(XML)
is the call that's failing, so you should write
io:format("XML=~p~n", [XML]),
base64:decode(XML)
the first line will print out the contents of XML in Erlang syntax, and the second line will fail when you get to the bad input.
Once you see the string you're trying to decode, the problem will probably be obvious (it's not a string or it's not a base64 string). If it is a correctly-encoded base64 string, then you can post that problem as a StackOverflow question and get a more useful response.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
“Uncaught ReferenceError: JQueryValidatorUI is not defined”?
Any familiar with jquery-validation-ui plugin for grails, when I use it I get the error in chrome script tab, that JQueryValidatorUI can not be found. ("Uncaught ReferenceError: JQueryValidatorUI is not defined")
Here's the code that the chrome is complaining about:
// amended from existing remote method
JQueryValidatorUI = {
remote: function(validator, constraint, value, element, params) {
if ( validator.optional(element) )
It can be found here:
https://github.com/limcheekin/jquery-validation-ui/blob/master/web-app/js/jquery-validation-ui/grails-validation-methods.js
Thanks in advance,
Mika
removed JQueryValidatorUI and left the remote function named as remoteCall and called this one instead of JQueryValidatorUI.remote and it works...