InstagramApiSharp
InstagramApiSharp copied to clipboard
Cannot Get Media Insights
I've:
- [x] {Searched} in Issues
- [ x] {Checked} Example projects
- [x] {Read} wiki pages
- [ ] Not sure
Issue category
- [x] Bug
- [ ] Feature Request
- [ ] Missing Feature
- [ ] Question
- [ ] Not sure
Language
- [x] C#
- [ ] VB.NET
Usage
- [x] Windows Form/Console app
- [ ] WPF app
- [ ] Asp .NET MVC
- [ ] Asp .NET Core
- [ ] Universal Windows Platform [UWP]
- [ ] Xamarin or Xamarin Forms
- [ ] Mono
- [ ] Other
Operating System
- [x] Windows
- [ ] Windows Server
- [ ] Linux
- [ ] Mac OS
- [ ] Other
Describe your issue
Calling the media_organic_insights endpoint (through GetMediaInsightsAsync
) results in an error with HTTP Error code 400, and the message: "Insights are not avaialble, try again later" (yes with the typo -- this seems to be an internal typo within instagram)
I am positive that I have done everything else correctly on my end.
Anyone have any idea why this might be, and can anyone reproduce?
you can try
await InstaApi.BusinessProcessor.GetFullMediaInsightsAsync(Media_ID);
@pall1024 I tried that already actually, but I keep getting an error with HTTP Error code 400 and no message
public async Task<IResult<InstaFullMediaInsights>> GetFullMediaInsightsAsync(string mediaId)
{
UserAuthValidator.Validate(_userAuthValidate);
try
{
var instaUri = UriCreator.GetGraphStatisticsUri(InstaApiConstants.ACCEPT_LANGUAGE, InstaInsightSurfaceType.Post);
var queryParamsData = new JObject
{
{"access_token", ""},
{"id", mediaId}
};
var variables = new JObject
{
{"query_params", queryParamsData}
};
var data = new Dictionary<string, string>
{
{"access_token", "undefined"},
{"fb_api_caller_class", "RelayModern"},
{"variables", variables.ToString(Formatting.None)},
{"doc_id", "1527362987318283"}
};
var request =
_httpHelper.GetDefaultRequest(HttpMethod.Post, instaUri, _deviceInfo, data);
var response = await _httpRequestProcessor.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();
if (response.StatusCode != HttpStatusCode.OK)
return Result.UnExpectedResponse<InstaFullMediaInsights>(response, json);
var obj = JsonConvert.DeserializeObject<InstaFullMediaInsightsRootResponse>(json);
return Result.Success(ConvertersFabric.Instance.GetFullMediaInsightsConverter(obj.Data.Media).Convert());
}
catch (HttpRequestException httpException)
{
_logger?.LogException(httpException);
return Result.Fail(httpException, default(InstaFullMediaInsights), ResponseType.NetworkProblem);
}
catch (Exception exception)
{
_logger?.LogException(exception);
return Result.Fail<InstaFullMediaInsights>(exception);
}
}
@pall1024 Yep, that's what I did. Were you able to reproduce the issue or is it working for you?
sample code download
http://gofile.me/3dJWl/keIJ3ZRBM