Call Realm Administration API with Application ID results in 404 Not Found

Hi,

I’m trying to use the Realm Administration API and I can call the base endpoints like create an access token and get a list of applications. But when I take any of the application ids (from the _id field) they all return 404 Not Found for all endpoints.

I gave the API key I set up all the permissions available.

What am I doing wrong? :sweat_smile:

Hi @Max_Karlsson,

I’m having the same issue, all calls to the API return 404 page not found.

Did you find a solution to this?

Thanks
Will

Hey @varyamereon,

Unfortunately, I didn’t. Haven’t heard anything from Realm about it either.

I’m honestly pretty close to giving up on Realm altogether and replace it with a competitor.

@Max_Karlsson Can you give an example code snippet of how you are making this admin API call that always returns a 404?

Hi All – In addition to the code snippet that Ian mentioned, it would also be helpful to confirm that you’re following the steps for an Atlas Programmatic API key and that the key has project owner permissions for the project where your applications are. Sounds like this is the case, but sometimes we see confusion between Atlas API keys and Realm’s API key authentication.

Hi @Ian_Ward and @Drew_DiPalma, if someone would have reached out to this ticket 4 months ago when I posted it I might have been able to oblige, but I can’t even remember why I needed to use that endpoint now, so unfortunately I can’t help.

Sorry about that @Max_Karlsson - we don’t really have a SLA governing our community forums but in the future you can always open a support ticket which does have a SLA tracking system in place.

For this specific issue, we don’t see any reason why this wouldn’t work so likely there is just some confusion in the implementation. Would love to clean this up in the docs but we would need to know what is not clear in order to fix it.

Sorry, @Ian_Ward I didn’t mean to come across as entitled. I realise that this is just the community support forum. I just wanted to point out that the time that’s passed since I posted this question is too long for me to remember what I was trying to achieve or how. I don’t even remember which documentation I used, but I know I followed it to a tee :sweat_smile:

Perhaps @varyamereon will be better equipped to answer since he’s worked on it more recently.

@Drew_DiPalma re-reading the instructions I have found out what I was doing wrong. The call to get an access_token was always successful. I was then making calls with Postman and adding the token to the Authorization like so:

This was always returning 404 Page not Found. This morning I copies the curl request and replaced with my access token. It’s added to the headers in a different way and I was able to successfully make requests this way:

So it’s all in the details :wink:

Thanks for your help anyway, @Max_Karlsson I hope you manage to get it sorted.

Will

Hi Drew,

I’m experiencing a similar problem. I authenticate successfully using the following code;

private string _authUrl = "https://realm.mongodb.com/api/admin/v3.0/auth/providers/mongodb-cloud/";
private string _baseUrl = "https://realm.mongodb.com/api/admin/v3.0/";

string body = JsonConvert.SerializeObject(new { username = _publicApiKey, apiKey = _privateApiKey });
StringContent requestContent = new StringContent(body, Encoding.UTF8, "application/json");

using (HttpClient client = new HttpClient { BaseAddress = new Uri($"{_authUrl}") })
{
	client.DefaultRequestHeaders.Clear();
	client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

	HttpResponseMessage response = await client.PostAsync("login", requestContent).ConfigureAwait(true);

	if (response.IsSuccessStatusCode)
	{
		string content = await response.Content.ReadAsStringAsync();
		_authResponse = JsonConvert.DeserializeObject<AuthResponse>(content);
		_authResponse.Expires = DateTime.Now.AddMinutes(25);
	}
}

Then I try getting the app IDs using;

using (HttpClient client = new HttpClient { BaseAddress = new Uri($"{_baseUrl}") })
{
	client.DefaultRequestHeaders.Clear();
	client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
	client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _authResponse.AccessToken);

	HttpResponseMessage response = await client.GetAsync($"groups/{_projectId}/apps").ConfigureAwait(true);
}

This returns a “403 Forbidden” response.

If I attempt to create a user with the following;

	string body = JsonConvert.SerializeObject(new { email = userName, password = $"{pin}" });
	StringContent requestContent = new StringContent(body, Encoding.UTF8, "application/json");

	using (HttpClient client = new HttpClient { BaseAddress = new Uri($"{_baseUrl}") })
	{
		client.DefaultRequestHeaders.Clear();
		client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
		client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _authResponse.AccessToken);

		HttpResponseMessage response = await client.PostAsync($"groups/{_projectId}/apps/{_appId}/users", requestContent).ConfigureAwait(true);
	}

I get a “404 Not Found”.

I have followed the instructions at Authentication API, Find a Project ID,
Application ID and User APIs but have not managed to resolve the issues.

Hi All,

The 404 error can happen if you copied the API path by highlighting the string from the documentation instead of using the copy icon. Doing so can lead to copying across hidden UTF characters which will cause this issue. Please use the copy icon as shown below to avoid this issue.

Regards
Manny

1 Like