How to set request parameter for 'database' in Google API explorer? - google-apis-explorer

After entering '/projects/ABCDEFG/databases/(default)/documents/' to adress the database, the pattern description for the 'Request parameter' for 'database' states the following:
" database does not match pattern: /^projects/[^/]+/databases/[^/]+$/ "
This is cryptic to me and my attempts to interprete the pattern didn't work out. Also the documentation doesn't reflect it.
Can somebody provide an example, please?
please have a look on the screenshot:

Related

HPP Incorrect hash

I send a request to the sandbox to "Pay By Link".
URL: https://pay.sandbox.realexpayments.com/pay
I get an error in response.
{"errors":[{"resultCode":508,"internalErrorCode":61000,"errorMessage":"Incorrect hash. Please check your code and the Developers Documentation."}]}
The hash is calculated correctly (the values obtained through the SDK and calculated manually are the same).
This is possible with the wrong shared secret.
I use the values of the MerchantId and the SharedSecret in my account on the https://developer.globalpay.com/gp_api_credentials/
(My Account->Ecomm API Credentials->Sandbox Credentials)
How to fix the error?
Can i change the "Ecomm API Credentials->Sandbox Credentials" ?
The server reply is often completely wrong, so don't believe the error message it tells you. Remove all optional config field values (such as CardStorageEnabled) and try again. Then it should work, and after that you can re-enable the optional fields one by one to see which one causes the error.

Newsletter2Go endpoint /forms/submit{{form_id}}

I created a wrapper for using the newsletter2go endpoint
https://api.newsletter2go.com/forms/submit/{{form_id}}
When I post the request to that ep w/ an form_id I get the following response:
http status: 400
code: 10020
error message: Bad Request (invalid code xxxx)
Im using the id from the n2go backend:
Can anyone tell me whats about the error code 10020? The api docs containing nothing about that.
This is probably because you used big letters in your form_id. I had the same problem. The support told me, that only small letters are allowed.
I found finally out what the form_id have to be. It's the value you see in the Opt-In Email for the n2g argument, for example:
https://subscribe.newsletter2go.com?n2g=dummy-code-here
Otherweise check the sourcecode of the Embedded Form, there is a script in it which contains the form id.
Maybe this helps someone one day.

Xcode: "loginUser" couldn't be opened when trying to read a JSON

I am building an app that logins the users by reading a JSON, but something weird is happening and I do not understand why. So, when a user enters a valid username & password, it works fine but when a user enters them wrongfully, I am getting this error:
“loginUser” couldn’t be opened.
This is the code I am using for this:
if let url = URL(string: "http://www.url.com/url/loginUser?loginAlias=" +
txtUser.text! + "&loginPassword=" + txtPassword.text!) {
Extended code: https://textuploader.com/dnq7r (I was having troubles pasting it here)
I have tried to see the JSON through a web browser and it has this structure when a user enters a valid username & password:
{"alias":"user","firstLogin":true,"id":146,"isEnllum":false,"latitude":00.0000,
"longitude":0.000000,"townId":2,"townStr":"Town1","reply":1,"replyStr":"","role"
:2,"token":"yyjn7q0cia","urlVersion":"https:\/\/we.tl\/t-CX3jqO9Si8"}
But when not:
{"error":3,"isEnllum":false,"townId":2,"reply":2,"replyStr":"Username &
password are wrong","urlVersion":"https:\/\/we.tl\/t-CX3jqO9Si8"}
As you can see, both JSON files have the same structure, so I that is why I can't figure out what is wrong.
For the moment I can manage when a user enters a username & password wrongfully by using try and catch:
catch {
let alert = UIAlertController(title:"Error", message:
"Username & password are wrong", preferredStyle:
UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title:"Ok", style:
UIAlertAction.Style.default, handler:nil))
self.present(alert, animated:true, completion:nil)
print("Error: ",error.localizedDescription) /*this prints “loginUser” couldn’t be
opened.*/
}
Although, I would like to know the reason of why is this happening, and fix it if it is possible.
Thank you in advance
I see you're using the method Data(contentOf:) method to synchronously fetch data from a network URL. In the second case (empty/wrong username/password), the URL string formed doesn't correspond to an existing network resource, hence the error.
The error effectively tells you resource not found, so you can use the error thrown to show custom messages to the user (instead of if(user=="" || password=="")).
You can print the URL you're hitting and check if it's valid in the browser directly.
On a different note, making network requests synchronously isn't recommended as it can block your threads, UI and make your app crash, instead use URLSession's async tasks to achieve the same.

Hue API can't turning light on over browser command line

I tried to put my Hue Lamp on with the Clip API debug tool (as here explained: http://www.developers.meethue.com/documentation/getting-started ) and all works fine.
Now i want to do the same thing over the browser command line and i dont know how to write the url. I tried some variations but none worked....
The url should look something like this:
http://192.168.0.18/api/MyHashcode/lights/2/state{"on":true}&mode=put
The problem is the json code shown in the messagebody (link above), i dont know how to embed it in the url. How is the right syntax to get this working?
Thanks in advance,
kyi
In order to modify light state, you have to use a PUT method where the JSON payload is in the BODY of the HTML request. You can't put the JSON in the URL query string.
You can, however, send JSON to the bridge in many languages. Here is an example using AppleScript:
-- define baseUrl to point to your Hue hub address and one of the keys in your whitelist
set baseUrl to " http://YOUR-HUB-IP/api/YOUR-WHITELIST-ENTRY"
-- define some JSON to set a light state
set lightStateOn to the quoted form of " {\"on\": true,\"bri\": 254,\"hue\": 8000,\"sat\": 254} "
-- send the JSON to set a light state (on and with specified hue, saturation, and brightness)
do shell script "curl --request PUT --data " & lightStateOn & baseUrl & "/lights/1/state/"

Google Maps Geocoding XML service returns error via Curl when city name with more than 1 word is used

I am using the following Google Maps Geocoding service via a php script
http://maps.googleapis.com/maps/api/geocode/xml?address=
I have already tried curl and file_get_contents but none of them worked. The problem is when I use city name with one word it works but when I use city name with two words then I do not get anything back from the service but the following error
That’s an error.
Your client has issued a malformed or illegal request. That’s all we know.
Below is some code snippet from the script
$city = $_GET["c"];
$url="http://maps.googleapis.com/maps/api/geocode/xml?address=$city&sensor=false";
$data = curl_download($url);
//$data = file_get_contents($url);
echo $data;
I have also uploaded the script to the location below
01)http://www.javeria.com/sites/travel/map/googlemap.php?c=Houston (works)
02)http://www.javeria.com/sites/travel/map/googlemap.php?c=New+York (does not work)
When invoked with 02) it won't display the map instead I am masking the error to display a user friendly message.
I would appreciate any help into this matter.
Try using + between the words. I am doing essentially the same thing - and that change makes it work for me.