schollz / cowyo

A feature-rich wiki webserver for minimalists :cow: :speech_balloon:
https://cowyo.com/
MIT License
920 stars 69 forks source link

How to POST using curl? #128

Closed twocow closed 6 years ago

twocow commented 6 years ago

I know there is the cowyodel repo. But it doesn't seem to work with access code set. And I would prefer a simpler way to POST like curl which supports authorization headers. I have tried POST-ing as a Json struct, but it doesn't seem to work. Can you please help?

schollz commented 6 years ago

Sure, its very easy:

curl -H "Content-Type: application/json" -X POST -d '{"page":"testpost","new_text":"hello, world"}' https://cowyo.com/update

That will change the page at https://cowyo.com/testpost

twocow commented 6 years ago

Thanks.

How do I upload a file using curl?

schollz commented 6 years ago

You should just do a curl POST to /uploads with the file data in the form file.

twocow commented 6 years ago

I tried and I'm failing.

curl -d "@payload.md"

Can you please give me a working example command?

DanielHeath commented 6 years ago

With an access code set, you need to add -H 'Authorization: <access-code>' or similar I think.

DanielHeath commented 6 years ago

Once https://github.com/schollz/cowyo/pull/129 is merged, the login page will include (browser-invisible) instructions for curl users.

DanielHeath commented 6 years ago

That's merged now; you should get inline instructions if you update to the latest and try again.

schollz commented 6 years ago

Thanks @DanielHeath!