[GH-ISSUE #78] Fresh Install: Cannot POST /api/files/Default #77

Closed
opened 2026-02-27 15:54:52 +03:00 by kerem · 7 comments
Owner

Originally created by @dwenschhof on GitHub (Sep 28, 2017).
Original GitHub issue: https://github.com/RD17/ambar/issues/78

Hi all,
I did a fresh install and have Ambar running at http://10.0.1.9:80. Looking through the API docs, I tried to PUT my test.txt file using (test.txt file exists in my current directory):

curl -X POST http://10.0.1.9:80/api/files/Default/test.txt -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' -F file=@test.txt

And I get the response:
Cannot POST /api/files/Default/test.txt

So, then I checked to see what Sources exist using:
curl -X GET http://10.0.1.9:80/api/sources

and I receive an empty set:
[]

Is the reason I am getting the "Cannot POST" error due to no sources existing? If so, I can not find anywhere that documents how to create a new source or endpoint? How is this done?

Thanks in advance.

Originally created by @dwenschhof on GitHub (Sep 28, 2017). Original GitHub issue: https://github.com/RD17/ambar/issues/78 Hi all, I did a fresh install and have Ambar running at http://10.0.1.9:80. Looking through the API docs, I tried to PUT my test.txt file using (test.txt file exists in my current directory): curl -X POST http://10.0.1.9:80/api/files/Default/test.txt -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' -F file=@test.txt And I get the response: Cannot POST /api/files/Default/test.txt So, then I checked to see what Sources exist using: curl -X GET http://10.0.1.9:80/api/sources and I receive an empty set: [] Is the reason I am getting the "Cannot POST" error due to no sources existing? If so, I can not find anywhere that documents how to create a new source or endpoint? How is this done? Thanks in advance.
kerem 2026-02-27 15:54:52 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sochix commented on GitHub (Sep 29, 2017):

Hello @dwenschhof ! Did you have authentication enabled on you Ambar instance?

<!-- gh-comment-id:333106998 --> @sochix commented on GitHub (Sep 29, 2017): Hello @dwenschhof ! Did you have authentication enabled on you Ambar instance?
Author
Owner

@dwenschhof commented on GitHub (Sep 29, 2017):

Hi @sochix , thanks for your response! I currently have "auth": "none" in my config.json. Does this need to have a different value for me to do a POST?

Thanks again.

<!-- gh-comment-id:333132222 --> @dwenschhof commented on GitHub (Sep 29, 2017): Hi @sochix , thanks for your response! I currently have "auth": "none" in my config.json. Does this need to have a different value for me to do a POST? Thanks again.
Author
Owner

@proteusos commented on GitHub (Oct 2, 2017):

it's the same problem i have.

curl -X POST \ http://MYIP/api/files/Testsource/test.pdf \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -F file=@test.pdf

curl: (6) Could not resolve host:
curl: (26) couldn't open file "test.pdf"
curl: (6) Could not resolve host:
curl: (6) Could not resolve host: multipart
curl: (6) Could not resolve host: boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
curl: (6) Could not resolve host: \

by the way...is it possible to select or name a tag by uploading a file with the gui-uploader?

thanks for help

<!-- gh-comment-id:333565320 --> @proteusos commented on GitHub (Oct 2, 2017): it's the same problem i have. curl -X POST \ http://MYIP/api/files/Testsource/test.pdf \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -F file=@test.pdf curl: (6) Could not resolve host: \ curl: (26) couldn't open file "test.pdf" curl: (6) Could not resolve host: \ curl: (6) Could not resolve host: multipart curl: (6) Could not resolve host: boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' curl: (6) Could not resolve host: \ by the way...is it possible to select or name a tag by uploading a file with the gui-uploader? thanks for help
Author
Owner

@sochix commented on GitHub (Oct 13, 2017):

Hi! It's error in our documentation.

Use api/files/uiupload/test.pdf

Here is sample python code

    filename = 'test.txt'
    files = {'file': (filename, 'TEST FILE CONTENT', 'application/vnd.ms-excel', {'content-type': 'multipart/form-data'})}
    url = 'https://app.ambar.cloud/api/files/uiupload/{0}'.format(filename)
    headers = {'ambar-email': 'YOUR_EMAIL', 'ambar-email-token': 'YOUR_TOKEN'}
    
    r = requests.post(url, files = files, headers = headers)
    print(r.status_code)
<!-- gh-comment-id:336426220 --> @sochix commented on GitHub (Oct 13, 2017): Hi! It's error in our documentation. Use `api/files/uiupload/test.pdf` Here is sample python code ``` filename = 'test.txt' files = {'file': (filename, 'TEST FILE CONTENT', 'application/vnd.ms-excel', {'content-type': 'multipart/form-data'})} url = 'https://app.ambar.cloud/api/files/uiupload/{0}'.format(filename) headers = {'ambar-email': 'YOUR_EMAIL', 'ambar-email-token': 'YOUR_TOKEN'} r = requests.post(url, files = files, headers = headers) print(r.status_code) ```
Author
Owner

@proteusos commented on GitHub (Oct 15, 2017):

thanks...the code is working, but where can i paste the path for the file. Or do i need to read the file with python first? Where u paste 'TEST FILE CONTENT' i can only save a string. The curl command in your doc is working now...thanks for that.

Question:
Can i create a tag or something else, when i upload files?

<!-- gh-comment-id:336692767 --> @proteusos commented on GitHub (Oct 15, 2017): thanks...the code is working, but where can i paste the path for the file. Or do i need to read the file with python first? Where u paste 'TEST FILE CONTENT' i can only save a string. The curl command in your doc is working now...thanks for that. **Question: Can i create a tag or something else, when i upload files?**
Author
Owner

@sochix commented on GitHub (Nov 21, 2017):

@proteusos as for now not

<!-- gh-comment-id:346067232 --> @sochix commented on GitHub (Nov 21, 2017): @proteusos as for now not
Author
Owner

@proteusos commented on GitHub (Nov 24, 2017):

@sochix thanks for your response

it's working now. Your blog describes, that i can hand over a ":sourceId" to the POST request. this could be Dropbox or in the example "books". So that i have a better structure, if i upload files via the rest api. So the standard tag/source is ":uiupload". That would be great, if you can implement this, or is it still possible?

https://blog.ambar.cloud/ambar-use-case-integrated-parse-and-search-solution/

<!-- gh-comment-id:346751089 --> @proteusos commented on GitHub (Nov 24, 2017): @sochix thanks for your response it's working now. Your blog describes, that i can hand over a "**:sourceId**" to the POST request. this could be Dropbox or in the example "books". So that i have a better structure, if i upload files via the rest api. So the standard tag/source is "**:uiupload**". That would be great, if you can implement this, or is it still possible? **https://blog.ambar.cloud/ambar-use-case-integrated-parse-and-search-solution/**
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ambar#77
No description provided.