API proxy import failing with 401 Unauthorized

Not applicable

Hi,

I get a 401 Unauthorized when trying to import a proxy bundled as a zip file using the following endpoint

POST https://api.enterprise.apigee.com/v1/organizations/my-organisation/apis?action=import&name=my-api-pr....

This used to work for long time, but somehow it doesn't work anymore. I checked the user credentials are valid, I can login manually, and can see the API proxy that's trying to update.

Any ideas?

1 15 1,745
15 REPLIES 15

Not applicable

Hi @Julio Rincon,

If your password contains any special characters, then you need to provide it in quotes.

adas
New Member

If the credentials are valid there's no reason why this shouldn't work. One of the possibilities is that your org has been decommissioned or your user has been marked inactive due to prolonged inactivity. Is your org a "trial" org by any chance ? Can you give me your org name.

We cleaned up some unused "trial" orgs earlier this year, especially orgs which didn't have any activity for over 2 months. You can find more info here

my org is mg-nonprod and the password indeed contains "at" symbol. I tried with quotes, single quotes, no luck.

Just signup for a new account using different Email Address

@Julio Rincon ,

Welcome to Apigee Community 🙂 Thank you for highlighting this issue. I see issues with CURL command line documented in API documentation page. We will keep you posted on this

For time being see alternative solution till we figure out issue with CURL command line that is documented. API Endpoint is working, I have just verified above API using my account, which also has special characters & worked for me. Please see steps below that worked for me using a valid API Proxy bundle. I am attaching the sample bundle in case if you would like to verify once with same.

See attached screenshot for reference.

2622-proxyupload.png

UPDATE :

@Julio Rincon , I can able to reproduce this issue with your org. @arghya das , @Julio Rincon resetting the password , Logging Out & Loggin In fixed the issue. Edge UI Says, Due to security policies you need to reset the password again. After resetting the password, it worked for me.

@arghya das , Heard from support that they have seen this issue earlier & resetting the password fixed the issue. Not sure about root cause, finding same will be interesting.

Actually I tried initially both CURL and the doc page neither worked. I tried again with the sample bundle you sent, I got the same error, 401 Unauthorized. Do you think it could be some missing permission? I usally get 403 forbidden in those cases, but not sure if that's always the case.

@Julio Rincon

Insufficient permission or privileges would be a 403 not a 401. 401 is being thrown most likely because curl is not handling your password very well due to the special characters in it. Can you try one of the approaches I mentioned below and see if it works.

@arghya das, I have even tried with Authorization header instead of -u option. It's not working. I believe it might be some other issue. OP also says, he tried same with doc page which should work with special characters too. I have tried same with special characters & worked for me.

@Julio Rincon , Seems like permissions issue to me. Can you able to login & create API proxies using UI ? Are you using org admin role credentials to make API call ? Are you on trial org / paid org ?

@Julio Rincon ,

Below curl call is working for me, Instead of -u option, i have used base 64 encoded username , password Authorization header.

curl -X POST --header "Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXX" -F "file=@sampleHello_rev1_2016_05_05.zip" "https://api.enterprise.apigee.com/v1/organizations/{YOURORGNAME}/apis?action=import&name=sampleHello"

2624-screen-shot-2016-05-05-at-122928-pm.png

@Julio Rincon , I can able to reproduce this issue with your org. @arghya das , @Julio Rincon resetting the password , Logging Out & Loggin In fixed the issue. Edge UI Says, Due to security policies you need to reset the password again. After resetting the password, it worked for me.

@arghya das , Heard from support that they have seen this issue earlier & resetting the password fixed the issue. Not sure about root cause, finding same will be interesting.

adas
New Member

Ahh...so that's the problem. Its nothing Apigee specific. If your password contains '@' or '&" characters you need to encode them. Here are few options that you may want to try:

- encode the '@' and '&' characters in your password while making the curl call

- pass the extra option --data-urlencode in the curl command (only specific versions of curl)

- try to pass the username and password as part of the url within double quotes

- use Apigee's smart docs as suggested in the other post

- use some other REST client like Postman(Chrome) or RESTClient (Firefox)

The --data-urlencode option is available in cURL 7.18.0 and higher. All these options should help.

As mentioned above, I've already tried the smart docs without luck 😞 I don't think it's curl related. I also tried setting the password URL encoded in the Smart Docs without luck. I'll see if changing the password to plain chars helps....

adas
New Member

@Julio Rincon I see an org level flag for passpord policy set for your org. If you do not want the password policy enforced, you can get the flag removed. Its a system admin call, so you would have to raise a support ticket to get this done. You can simply do GET /v1/o/orgid to see what I am referring to.

Thanks @arghya das @Anil Sagar and others for your quick responses. The account is managed by the ops team, they given up investigating, and don't want to change password either. So apparently they are going to raise a support request. In the meantime, I've got a separate personal account to manage proxies for now.