HTTP 401 (Unauthorized)

I need help in my code

local HttpService = game:GetService('HttpService')
local To = 'xxxxxxxxxx'
local Voice = 'The quick brown fox jumps over the lazy dog'
local Url = 'https://api.nexmo.com/v1/calls'
local Data = {
	['to'] = {
		['type'] = 'phone',
		['number'] = To
	},
	['from'] = {
		['type'] = 'phone',
		['number'] = To
	},
	['ncco'] = {
		['action'] = 'talk',
		['text'] = Voice,
		['language'] = 'en-AU',
		['style'] = '3',
	}
}
local Encoded = HttpService:JSONEncode(Data)
HttpService:PostAsync(Url, Encoded)

I tried to get a notification on my device, this won’t use person’s voice it’s using text to speech.
I have HTTP Requests On.
image
Any scripts will help!

1 Like

https://api.nexmo.com/v1/calls

I’m unable to visit this site.

That means you are unauthorized to access the API, do you have the correct API key?

@Forummer That is because that link is for the API calls, use https://nexmo.com

I know what it’s for, I was inferring that the url in question is unreachable.

There are helps in that website but, they show example of codes, they did not show an example of lua code

Here is an example of curl code:
image

The HTTP 401 that you’re getting back from the API is your answer, you aren’t authorized to access this, why? Simple, you’re not passing an Authorization header which this API requires. I would assume it’s restricted to anyone with an API key… I recommend consulting the website for the API you’re using.

This is an example I found from the documentation and you can see that an Authorization header is passed in the curl.

How to pass a Authorization header to the api using a roblox script? I’m new to HttpService

You need to use :RequestAsync instead.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.