My second point about it not really working… or being bad documentation…
https://developers.shotgridsoftware.com/rest-api/#making-requests
here, they say that you should be able to get a list of your projects (or at least that is what it seems like)
with something like:
curl -X POST https://yoursite.shotgunstudio.com/api/v1.1/entity/projects/1
-H 'Authorization: Bearer
-H ‘Accept: application/json’
but when I do that (in c#)
public async Task<string> GetProjects(string token, string BaseAddress)
{
var endpoint = "entity/projects/1";
Console.WriteLine($"Requesting projects from {BaseAddress + endpoint}");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var response = await client.PostAsync(BaseAddress + endpoint, null);
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Request succeeded.");
return await response.Content.ReadAsStringAsync();
}
else
{
Console.WriteLine("Request failed.");
Console.WriteLine($"Response: {response.StatusCode}");
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response: {data}");
return string.Empty;
}
}
I get
Response: BadRequest
Response: {“errors”:[{“id”:“1e136154d45dd11f39a6a7ab3c8ce8b9”,“status”:400,“code”:103,“title”:“Request Parameters invalid.”,“source”:{“revive”:[“revive is missing”]},“detail”:null,“meta”:null}]}
Now, I know that my code is mostly ok because when I do the same thing for Assets, using a similar pattern shown in the sample, it works, to a degree
public async Task<string> GetAssets(string token, string BaseAddress)
{
var endpoint = "entity/assets";
Console.WriteLine($"Requesting assets from {BaseAddress + endpoint}");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var response = await client.GetAsync(BaseAddress + endpoint);
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Request succeeded.");
return await response.Content.ReadAsStringAsync();
}
else
{
Console.WriteLine("Request failed.");
Console.WriteLine($"Response: {response.StatusCode}");
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response: {data}");
return string.Empty;
}
}
this returns data like:
“relationships”:{},“id”:1411,“links”:{“self”:“/api/v1.1/entity/assets/1411”}}],