How to use Docverter from Httpie? - pandoc

I'm trying to render adocument using docverter from httpie. All the examples are for Curl. I tried
http -f POST http://c.docverter.com/convert from=markdown to=html input_files#example.txt --output out.html
But the website throws an error
TypeError at /convert
can't convert Symbol into Integer

You had it pretty close. Your http invocation should look like this:
http --form -f POST http://c.docverter.com/convert from=markdown to=html input_files[]#example.md --output out.html && open out.html
While debugging I found a bad typo and shipped v1.0.1 and installed it on the public instance.

Related

Curl command not uploading file contents

Hi I am using cURL command to upload a file which is a POST request to my local machine service.
I am using following commands to upload
curl -i -X POST -H "Content-Type: multipart/form-data" -F
"/Users/myName/Folder/file.csv" http://localhost:port/api/fileupload
In my application side I am using spring frameworks web binding to receive the file
Following is the code snippet
public ResponseEntity importDimensions(#RequestBody MultipartFile file) {
// file is variable is always null
}
What am I missing here?
You need an # sign before the filename, like this: #/Users/myName/Folder/file.csv.
And if your server-side code is expecting a parameter named file then you need to do this:
-F "file=#/Users/myName/Folder/file.csv"

Curl Request : response using curl Request is not properly formatted(xml)

i am loading xml as String from Remote using curl as below:
$ curl -i -H "Accept: application/xml" -X GET "URL Here"
but response is not xml format, hence not easily readable.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><RunConfig <PipeLineXmlVersion>1.0</PipeLineXmlVersion><DateTime>20161128_160859</DateTime><Analysis><Lane>1</Lane><PipeLine>run_multiplexed_auto_start_v4.0.sh</PipeLine><Version>4.0</Version><Mismatch>1</Mismatch><MergeLane>0</MergeLane<Version>4.0</Version></Analysis></RunConfig>
When i try the same API using some REST client then i can see the proper xml.
As i searched, Accept header should work but unfortunately not in my case.
Please help me with this.
Thanks.
If what you mean by "not proper" is the fact that the response is not pretty printed (i.e. lack spaces and indent), there are plenty of command line tools to format xml.
For example:
curl ... | xmllint --format -
Here, you pass the response of curl to xmllint (part of xmllib2-utils), which will format your answer. The - in the end tells the tool to print the result in the console.
Have a look at this question for more ways to achieve it.

Load GeoJSON file into Apache CouchDB

I am working on Windows10 and tried to load a geojson file into my couchdb via the "curl" command and a POST request in the cmd which looks like that:
C:\Program Files\cURL\bin>curl -d #path-to-my-data\data.geojson -H "Content-type: application/json" -X POST http://127.0.0.1:5984/_utils/database.html?-dbName-
and then I get the following error:
{"error":"method_not_allowed","reason":"Only GET,HEAD allowed"}
On http://couchdb-13.readthedocs.org/en/latest/api-basics/ it is said, that "If you use the an unsupported HTTP request type with a URL that does not support the specified type, a 405 error will be returned, listing the supported HTTP methods."
When I try that with a PUT request, I get the same error.
I validated the json with jsonlint so this should not be the problem.
I tried several tutorials like "Three Steps to CouchDB Heaven …" or "Export & Import a Database with CouchDB" but none of them seems to work.
So I am not sure, where the problem is. Do I need to make changes in my geojson file, or something else?
thanks for your help
The needed curl command just looks like that:
curl -H "Content-Type: application/json" -X POST http://localhost:5984/db -d #C:\Users\Name\Desktop\data.geojson

Cannot get imgur v3 api request to authorize using curl or other bash utility

I'm trying to scrape some public data from imgur.com using the v3 imgur api but whenever I make a request using curl I'm getting a 401.
This is how I'm calling the API (using this example from the example python app) -
curl -F "Authorization=Client-ID <my_client_id_provided_by_registering_my_app>" https://api.imgur.com/3/gallery/hot/viral/0.json
I've also tried
curl -F "client_id=<my_client_id>" https://api.imgur.com/3/gallery/hot/viral/0.json
So my question is, what format is the imgur api expecting for the auth header and how can I leverage it using curl or some other common bash utility?
The switch -F (or --form) is for sending HTTP forms. What you should use instead is -H (--header):
curl --header "Authorization: Client-ID $YOUR_ID" https://api.imgur.com/3/gallery/hot/viral/0.json

GitHub issue creation API

I'm trying to create an issue with a GitHub repository:
curl -d '{"title":"my-new-repo","body":"my new issue description"}' https://api.github.com/repos/np98765/BattleKits/issues
This just returns:
{
"message": "Not Found"
}
I'm authenticating like this:
curl -u "user:password" https://api.github.com
What am I doing wrong?
http://developer.github.com/v3/issues/#create-an-issue
You don't seem to call POST in your curl request.
You could at least try (following "REST-esting with cURL"):
curl -X POST -i -d '{"title":"my-new-repo","body":"my new issue description"}' https://api.github.com/repos/np98765/BattleKits/issues
With -i for having a look at the response headers.
Just tried curl -u "$REPORTER":"$TOKEN" https://api.github.com/repos/$OWNER/$REPO/issues -d #$JSON_WITH_ISSUE and it worked.
This uses token authentication and reporter is my user, while owner of the repo is the user to whom I'm reporting the issue.

Resources