Getting 401 with custom app

Hi. I am building a custom app for the shortener TinyURL.com using URL Shortener, Branded Short Links & Analytics | TinyURL and keep getting a 401. I am either really close to being done or really far :slight_smile: I would appreciate having my code looked over. I removed all default comments in case tinyurl is not jsonc compatible. TIA

Base:

{
	"baseUrl": "https://api.tinyurl.com",          
	"headers": {                                          
		"Authorization": "Bearer {{connection.apiToken}}"  
	},

	"response": {
		"error": {                                        
			"message": "[{{statusCode}}] {{body.error}}"  
		}
	},

	"log": {
		"sanitize": [                                     
			"request.headers.authorization"               
		]
	}
}

Connections:Communication

{
	"url": "https://api.tinyurl.com",      
	"headers": {                                          
		"Authorization": "Bearer {{parameters.apiToken}}"   
	},

	"response": {
		"metadata": {                                    
			"type": "email",                              
			"value": "{{body.email}}"                     
		},
		"error": {                                        
			"message": "[{{statusCode}}] {{body.error}}"  
		}
	},

	"log": {
		"sanitize": [                                     
			"request.headers.authorization"               
		]
	}
}

Connections:Parameters

[
    {
		"name": "apiToken",
		"type": "text",
		"label": "TinyURL API Token",
		"required": true,
		"help": "[Help](https://tinyurl.com/app/settings/api)"
	}
]

Modules:Communication

{
	"url": "/create", 
	"method": "POST",
	"headers": {},   
		
	"body": {
		"url": "{{parameters.longUrl}}",  
		"alias": "{{parameters.alias}}"
	},        
	
	"response": {
		"output": "{{body}}"
	}
}

Modules:Mappable Parameters

[
	{
		"name": "longUrl", 
		"type": "url", 
		"label": "Long URL",
		"required": true, 
		"help": "[Manage](https://tinyurl.com/app/my-urls)"
	},
	{
		"name": "alias", 
		"type": "text", 
		"label": "Alias", 
		"required": false, 
		"help": "5 to 30 characters to be included.",
		"minLength": 5,
		"maxLength": 30
	}
]

I tried the same setup with what you have done and was able to Create a Token.

Maybe the token/key you are using is invalid? Can you try this app and see if you are getting the same error?

https://www.make.com/en/hq/app-invitation/6064dd2a3b72584346091288cf58d4b5

1 Like

I think the “copy api” button in my tinyurl.com account was keeping whitespace on both ends of the key that were not being trimmed. I got it to work and completed it. Thank you

https://www.make.com/en/hq/app-invitation/d5c60ce09fc540ff7a3c0cf24b1be000.

2 Likes