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.
Related
I have a script that sends POST requests to Apache load balancer to change status_D parameter of the specified worker. This is supposed to enable or disable worker (0 - enable, 1 - disable).
This used to work, but not anymore. Script is in Perl, but I tried sending the same request using curl, same result - status does not change.
If I open load balancer web page in browser and change it from there - it works.
I even captured browser's POST request parameters from the Apache log, copied and pasted them into curl command, but it still did not work, which makes me think that parameters are fine, but perhaps something has changed in Apache or proxy_balancer_module recently? Apache version is 2.4.52.0.1.
In new versions you need to add the referer in the http request.
curl -s -o /dev/null -XPOST "http://${server}:${port}/${manager}?" \
-H "Referer: http://${server}:${port}/${manager}?b=${balancer}&w=${worker}&nonce=${nonce}" -d b="${balancer}" \
-d w="${worker}" -d nonce="${nonce}" -d w_status_D=1
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?
I'm following the documentation on the Sonarqube web api for getting/setting properties. I'd like to set a property on project pi_core with the property name "appName" and the value "UCFE". Ultimately I want to fully automate this via PowerShell but for now I'm just trying to validate the concepts using curl just like the docs. My command is:
curl -u myID:myPassword -X POST http://myServer.ad1.prod:9000/api/properties?id=appName&value=UCFE&resource=pi_core
I've verified that my ID and password work by executing other generic web api calls that require admin authorization. When I try to run the above I get:
{"err_code":200,"err_msg":"property created"}'value' is not recognized as an internal or external command, operable program or batch file.
'resource' is not recognized as an internal or external command, operable program or batch file.
Any ideas why this command, which seems to me to be identical to the documentation except for the values, gets the above error?
To start with, close the URI in quotes;
curl -u myID:myPassword -X POST 'http://myServer.ad1.prod:9000/api/properties?id=appName&value=UCFE&resource=pi_core'
The & for a start will send 3 commands into the background if you don't enclose it and run that from a shell
API Documentation is so often incomplete, has limited testing, is thrown together, or even unintentionally gets caught in the escaping process when displaying on blogs.
When using curl on the command line, remember that the shell interprets the command first.
Your initial command: curl -u myID:myPassword -X POST http://myServer.ad1.prod:9000/api/properties?id=appName&value=UCFE&resource=pi_core, looks like this to the shell:
arg1: curl
arg2: -u
arg3: myID:myPassword
arg4: -X
arg5: POST
arg6: http://myServer.ad1.prod:9000/api/properties?id=appName
arg7: value=UCFE
arg8: resource=pi_core
Therefore, arg7, and arg8 above, were sent to cURL as arguments. cURL wouldn't have a clue what "value=UCFE" means, hence the error:
'value' is not recognized as an internal or external command
When you put quotes around a block of text that you want sent as one argument (say, the URL to cURL), it looks like this:
Command: curl -u myID:myPassword -X POST 'http://myServer.ad1.prod:9000/api/properties?id=appName&value=UCFE&resource=pi_core'
Interpreted:
Arg0: curl
Arg1: -u
Arg2: myID:myPassword
Arg3: -X
Arg4: POST
Arg5: http://myServer.ad1.prod:9000/api/properties?id=appName&value=UCFE&resource=pi_core
Sidenote - for the sake of completion;
It often doesn't matter whether the quotes are single or double, but they are different.
Case for single quotes: Some APIs, have $ signs in them. For example MYOB has many parameters like the following; In this case, if there are many of them, it may be easier to use single quotes: '?$filter=DateOccurred%20ge%20datetime%272016-07-25%2'. In this case, if there are many of them, it may be easier to use single quotes.
Case for double quotes: Lots of variables: "?id=$id&refresh=true¶mlist=$params&authredirect=$authlevel"
I am trying to read open source data available on "https://swapi.co/" using curl.
there is no authentication needed and only the GET Method could be used to query the schema and data according to their documentation.
I am having an error on the following command:
curl -x GET "http://swapi.co/api/"
I am getting the following error message
C:\Users*****>curl -x GET "http://swapi.co/api/"
curl: (5) Could not resolve proxy: GET.
Any idea?
kindest regards
-x (lower case x) is for setting a proxy, and you told it the proxy is named GET. (Which obviously was wrong since it can't resolve such a host name.)
Remove the "-x GET" and it'll work.
Want to use ldap_mod_add command with SSL on Centos but get the following error message;
PHP Warning: ldap_mod_add (): Modify: Server is unwilling to perform in ...
However the SSL ldapsearch command is working well;
ldapsearch -x -H ldaps://winsvr.intra -b dc=windows, dc=intra -D "DOMAIN\user"-w "123456"
The required Windows.pem file is in /etc/ssl/certs/windows.pem directory and has the appropriate line in /etc/openldap/ldap.conf.
Indeed getting above error message.
What else should I configure to work properly?
Updated:
Everything's OK. Problem was that I didn't recognize existing AD user. That's why the ldap_mod_add returned with above error messages (it couldn't add same AD user through ldap_mod_add).
The LDAP client in your PHP example is apparently doing an update, whereas the ldapsearch tool is doing a search, not to point too fine a point on it. The configuration of the server, the nature of the target entries involved, and any access controls involved might affect the update but not the search.