Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
How to create an Asset Directory subfolder via the API
-
Hi,
I am trying to follow the section "Create Directory Endpoint" on https://docs.inedo.com/docs/proget-reference-api-asset-directories-api and I am unable to create a subfolder with the following command:
curl POST https://<ProGet_server>/endpoints/<asset_dir>/<new_dir>/ --user <user>:<password>
I get "curl: (6) Could not resolve host: POST"
Can the online documentation be updated to give a full example instead of "POST .../dir/«path»"
Thanks,
Scott
-
@scusson_9923 said in How to create an Asset Directory subfolder via the API:
https://docs.inedo.com/docs/proget-reference-api-asset-directories-api
Hi @scusson_9923,
I think the issue is that you are missing the
-X
in your curl command which is making curl think the URL isPOST
instead. Could you please try the following command:curl -X POST https://<ProGet_server>/endpoints/<asset_dir>/<new_dir>/ --user <user>:<password>
Thanks,
Dan
-
@Dan_Woolf Hi Dan,
When I add -X, I get:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>when I use -d -X, I get:
curl: (6) Could not resolve host: POST
If it helps, our environment is load balanced with 3 web nodes.
Thanks,
Scott
-
Hi,
A little more info. Looking at the IIS log, I see:
2021-12-03 19:39:41 <ProGet_ClusterIP>7 POST /endpoints/<asset_dir>/<new_dir>/ - 443 - <Machine_IP>> curl/7.55.1 - 200 0 0 78
So we know it hits the ProGet server and returns success from IIS. Just very confused on "curl: (6) Could not resolve host: POST" from curl.
Thanks,
Scott
-
Hi @scusson_9923,
I just wanted to make sure you were using the correct URL. It should be
https://<ProGet_server>/endpoints/<asset_dir>/dir/<new_dir>/
I wanted to make sure you had thedir
URL part between your asset directory and your folder path.What OS are you running the curl command from? I want to test this myself, but I know Linux and windows syntax can differ a bit.
Thanks,
Rich
-
@rhessinger Hi Rich,
Thanks! Adding the /dir/ worked. I still get the "curl: (6) Could not resolve host: POST" error on Windows. Linux is "curl: (6) Could not resolve host: POST; Unknown error". Can your online documentation be updated with the full command?
curl -d -X POST https://<ProGet_server>/endpoints/<asset_dir>/dir/<new_dir>/ --user <usename>:<password>
Thanks again,
Scott
-
Hi @scusson_9923,
It looks like the issue in the command is that you are using
-d
but not providing a value for it. So what is happening is that the-X
is being treated as the value of-d
and POST is being treated as the host. You should either use just-d
or remove the-d
and use-X POST
instead. I'm sorry I missed this before, but curl is not the best with error messages.As for our documentation, it is meant as general documentation. Mainly, you need to make a POST/GET/etc.. request to that URL. You can use any tool you would like (curl, Invoke-WebRequest, Postman, etc...) or call from your code directly.
If this is something you are planning to use a lot, I would suggest that you add your own custom Feed Usage Instructions or Package Install Instructions for your Asset Directory.
Thanks,
Rich
-
@scusson_9923Hi Rich,
if I just use -X I get the return:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>We plan on adding this in an automated build scenario, so there is a good chance we'll be using this regularly.
Thanks,
Scott
-
Hi @scusson_9923,
So after some further testing. I figured out this to be the valid request:
curl -d "" -X POST --user <username>:<password> http://proget.localhost/endpoints/public-files/dir/cli-api-test/
You could also use
api:<API key>
for the --user parameter. The last time I tested CURL, I didn't need to include the-d ""
, nor does their documentation. Using only -X apparently ignores the content-length header where-d ""
will add a content-length of 0.Hope this helps!
Thanks,
Rich
-
-