In uploadcare, I'm getting an empty 403 error when using the upload POST endpoint - uploadcare

I'm using a raw post since I'm using react native and I didn't see a react-native library.
I'm getting a 403 response when trying to upload using the raw upload form post- is there a setting that I need to set or is my public key not activated or something? I don't see a text response in the 403 response so not sure what the specific error is.
Here's my sample CURL from postman
curl -X POST -H "Content-Type: multipart/form-data; boundary=..."
-F "UPLOADCARE_PUB_KEY=foo"
-F "UPLOADCARE_STORE=1"
-F "file=#logo.jpg" "https://upload.uploadcare.com/base/"

Here are few things you should look at:
content-type is not needed here
reason for 4xx should be stated in response body or headers
make sure that you don't have typos in API key
make sure that automatic storing is enabled in the project or send "UPLOADCARE_STORE=auto"
make sure that your account is not blocked, has some quota left, file type is allowed, etc.
don't rely on Postman, check the command with cURL
This works:
curl -vv -X POST \
-F "UPLOADCARE_PUB_KEY=demopublickey" \
-F "UPLOADCARE_STORE=1" \
-F "file=#logo.png" "https://upload.uploadcare.com/

I see you are trying to use multipart upload, how big is logo.jpg? Are you able to upload the same file using the dashboard?

Related

How to get Bearer access token in Jmeter

I have problems to get Bearer access token in Jmeter. Problem's cause most probably is in
server authentication - do not really understand how to properly setup this in Jmeter.
curl consist of several parts:
curl -X POST -v https://xxxx.xxx.xx.lv/token -u
"d123c9e3-4e91-46db-931e-37e8a52b8c8d:0e7cb8ad50fe3686de05fcf46815abc0a9d7cd095c23f75446d933ccxyxy"
-d "grant_type=password" -d "username=xxxxxxx" -d "password=xxxxxx" -d "scope=scop"
I have tried to use HTTP AuthorizationManager, HTTP Request and HTTP Header Manager without any successful results. Any advices?
Thanks!
Tatjana
I think you should do something like:
HTTP Request sampler:
these protocol and Server Name bits can be moved to HTTP Request Defaults so you won't have to specify them for each and every HTTP Request sampler
HTTP Authorization Manager:
In general since JMeter 5.1 it's possible to create a test plan from curl command line, the option lives under "Tools -> Import from cURL" main menu entry:

Google FCM - can not subscribe to topic - returns 502 or "error INTERNAL"

Trying to subscribe device token to a topic on server. According to FCM server docs proceeding the request:
curl --header "Authorization: key=AAAA...qC1GXg" \
--header "Content-Type:application/json" \
-X POST -d '{}' \
"https://iid.googleapis.com/iid/v1/BY7kK...rbZ/rel/topics/mytopic"
which returns :
502. The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds
The same 502 is returned when I'm trying to get token info with "details" parameter, like this:
curl --header "Authorization: key=AAAA...C1GXg" \
"https://iid.googleapis.com/iid/info/BY7kK...rbZ?details=true"
While if not adding "details" parameter, it all ok - it returns 200 and json data:
{"applicationVersion":"24","attestStatus":"UNKNOWN","application":"com.my.app","scope":"*","authorizedEntity":"...","appSigner":"...","platform":"ANDROID"}
I have also tried a batchAdd:
curl --header "Authorization: key=AAAA...81GXg" \
--header "Content-Type:application/json" \
-X POST \
-d '{"to":"/topics/mytopic", "registration_tokens": ["BY7k...rbZ"]}' \
"https://iid.googleapis.com/iid/v1:batchAdd"
and it ends up with :
{"results":[{"error":"INTERNAL"}]}
Authorization key and device token I use should be OK, since I can get token data (without topics), and sending messages to that device (also using curl) works OK.
Still, this 502 is happening for more than 24h for me so far.
That's a new FCM project - I'm not migrating from GCM or anything. Android app is live on market for some time, but I haven't used cloud messaging there before.
Any ideas with what could be wrong here? Thank you.
Found the cause. In case if someone will make the same mistake:
My Android app is published under one Google account, while I have created a project in Firebase console under a different account.
Having the app and Firebase project under same Google account - and all works like a charm.
Meanwhile, Google maps API keys, which also are used in my Android app, were generated under that second account, and everything is OK.

Is this a GET or POST request in cURL?

curl https://api.creditcard.com/charge \
-H "x-apikey: API_KEY " \
-d email=user#host.com \
-d amount=9.99 \
It seems like a GET to me, but why would an API have a GET for charging a card? Shouldn't it be POST?
When -d as in post data is passed to curl, it will do a post request. So your request will perform a post request. If you want to see more about what request curl is doing, just add -v for more verbose output from the request (including what http method is used).
If you want to force a type of request, just add -XMETHOD where METHOD can be any of the HTTP verbs (GET/POST/...).

Gitlab API: How to generate the private token

This is what I tried:
curl http://git.ep.petrobras.com.br/api/v3/session --data-urlencode 'login=myUser&password=myPass'
Answer:
{"message":"401 Unauthorized"}
The problem is the data-urlencode CURL option. Since it's an HTTP POST you don't need to URL encode the data, and is actually encoding the & into & and causing your issue. Instead use the --data option.
curl http://git.ep.petrobras.com.br/api/v3/session --data 'login=myUser&password=myPass'
Also, be careful sending credentials over plain HTTP. It could be easily sniffed.
This is how:
$ curl http://git.ep.petrobras.com.br/api/v3/session/ --data-urlencode 'login=myUser' --data-urlencode 'password=myPass'
The solution pointed out by Steven doesn't work if your username or password contains characters that have to be urleencoded. The name=content format will urlencode the content part (the name part has to be urlencoded but login and password are fine).
To actually retrieve the private_token you can pipe the output of curl into jq like this:
$ curl [as above] | jq --raw-output .private_token
x_the_private_token_value_x
This way you can easily use it in a shell script.
Also, as Steven pointed out already, please use https instead so that your password is not transmitted in clear text across the wire.
Note: this workflow no longer works as of GitLab 8.6.0 as the default password has been removed.
Changelog: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG#L205
I only just noticed this and raised the issue. Leaving this note here to hopefully save someone else some time. Hopefully, this is a decision that will be reviewed and reverted.
Discussion/issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/1980

HTTP PUT deleting triples in sesame

I'm trying to use http PUT via cURL to update my triple store in openrdf-sesame, but I've hit a problem that I can't find a solution for.
When using POST, the triple data uploads perfectly.
But then using PUT, instead of adding the data provided, it deletes all the data from my repository. I've ran cURL in verbose mode, and it's giving back the expected HTTP status code.
I've added
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
to Apache Tomcat's web.xml,
Ive also tried the guide here: HTTP PUT Guide, but that hasn't helped either.
EDIT
Here are the cURL commands from my batch file:
call "%curl%" -# -X POST %endpoint%/statements -H "Content-Type:application/x-trig;charset=UTF-8" -d #%%X
call "%curl%" -# -X PUT %endpoint%/statements -H "Content-Type:application/x-trig;charset=UTF-8" -d #%%X
Which is essentially:
curl.exe -# -X POST http://myendpoint/statements -H "Content-Type:application/x-trig;charset=UTF-8" -d #MyTrigFile.trig
curl.exe -# -X PUT http://myendpoint/statements -H "Content-Type:application/x-trig;charset=UTF-8" -d #MyTrigFile.trig
For the moment, I've disabled authentication, but otherwise I'd also include a -u user:password argument.
I have just ran some tests using your exact way of invoking curl, and I can't reproduce the problem (using Sesame version 2.6.8): it works as expected here.
The only possible cause I can think of is that your TriG file has a syntax error which Sesame fails to report back.
Another possible problem is your expectations: the command as you execute it will completely clear the entire repository and replace the data with the contents of your TriG file. Were you perhaps expecting something else?
To further debug this, can you have a look in the Sesame server logs and tell us if it shows any warnings or errors? Server logs are viewable by going to http://<server:port>/openrdf-sesame/ in the browser and clicking 'System' in the menu on the left.