Curl Loading Data "Unauthorized" Error


#1

I’ve triple checked my Curl command, so I’m fairly certain it’s correct, however, I continually get an “unauthorized” error when I run it in my terminal. (I’m the only person on the project at this moment, so it’s not like I am lacking any permissions) Any ideas what I may be doing wrong?

Thanks!


#2

Could you please post the curl command you are using?


#3

This is the “template” I’m going off of:
curl -v -H “Content-Type: text/csv” -X PUT --data-binary @PATHtoFile
ENVIRONMENT/import/1/TENANT/TAG/CANONICALNAME/File.csv -u ‘Username’: ‘Password’

Do you want to see exactly what I wrote?


#4

Make sure your ENVIRONMENT has https://, not http://?
Or maybe there is a character in username/password that is not being escaped properly? You could always authenticate using a header instead: -H "Authorization: c3authtoken", which you can retrieve from the c3auth cookie after you’ve logged into the C3 static console


#5

Just to clarify - this c3authtoken is supposed to be a string approx 150 chars long? (I tried running it with the authtoken, and it didn’t run, it just opened up extra lines starting with carrots) (I’m sorry, I’m not very familiar with curl-ing)


#6

Yes, that’s the auth token you’re looking for.

The extra lines starting with angle brackets means you have a syntax error in your command, and a single command was not finished. (the same as if you typed echo "Hello, and hit enter/return, the shell would be waiting for a closing double quote character")