Using curl to insert an event into a calendar

Hello,

I am writing a command line script to put events into a calendar using curl. I managed to get this working by first creating a temporary local calendar file and then uploading this file to the server using these commands:

$command > $localfile
curl -T "$localfile" $url

This works perfectly, but I’d like to get rid of the local file. I’m looking for a way to pipe the output of $command straight to curl. Something like this:

$command | curl -T - $url

According to curl’s manual, the option T - should be what is required: read from stdin instead from a file. But if I use that option, I get this response:

  <?xml version="1.0" encoding="utf-8"?>
    <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
      <s:exception>Sabre\DAV\Exception\Conflict</s:exception>
      <s:message>PUT is not allowed on non-files.</s:message>
    </d:error>

Does any one know how to do this?

I’m not very experienced with cURL but -T (--upload-file) will try to upload the file. You’ll probably need to use --data or other parameters like --data-raw.
I’m afraid I cannot help you in detail, but maybe this solves it or is at least a hint in the right direction.

As this is more a cURL/Linux and not a specific Nextcloud question, you might get better answers on sites like stackoverflow.

Yes and no. :slight_smile:

I was thinking this could also be an issue specific to NC, maybe NC needs a special parameter or some option in the server’s settings to allow this kind of upload.

Try this one: $command | curl --data @- $url
If it doesn’t work try --data-raw or --data-urlencode parameters instead.

EDIT: Or maybe $command | curl -T . $url

And of course a very simple workaround if you want to get rid of the local file (but using it temporarily) would look like this:
curl -T "$localfile" $url && rm $localfile

@weka don’t know if https://www.getpostman.com/downloads/ is helpful for you to generate the correct curl command.

grafik -> grafik