I've confirmed that I have permissions to perform the request.
According to amazon's Cloud Search Dev Troubleshooting Guide the error I'm experiencing is likely due to the .net sdk using the wrong api version. I don't see a way to specify the api version explicitely.
I want to avoid having to manually create the http request.
I want to make the request through the SDK.
I've tried all the available versions of the SDK and all of them give me this error.
I've also tried specifying the request properties in various combinations. Nothing works.
Can anybody give me direction as to how I can resolve this issue?
Expected behavior: return info for all index fields
Actual behavior:
error -
"Result Message:
Amazon.Runtime.AmazonUnmarshallingException : Error unmarshalling response back from AWS. Response Body: {
"message": "Request forbidden by administrative rules",
"__type": "CloudSearchException"
}"
----> System.Xml.XmlException : Data at the root level is invalid. Line 1, position 1.
Code sample:
var _configClient = new AmazonCloudSearchClient(
WebConfigurationManager.AppSettings["CloudSearchAccessKey"],
WebConfigurationManager.AppSettings["CloudSearchSecretKey"],
new AmazonCloudSearchConfig
{
RegionEndpoint = RegionEndpoint.USWest2,
ServiceURL = WebConfigurationManager.AppSettings["CloudSearchUrl"]
});
await _configClient.DescribeIndexFieldsAsync(new DescribeIndexFieldsRequest())
CloudSearch is returning json, which you can see in your response body, and the SDK is trying to unmarshal that into xml. When you make a query directly, you can add &format=xml to get xml results. There should be an analogous option in the SDK.
Related
I have a request I'm making to the Bing Ads API that looks like this:
var _campaignManagementService = new ServiceClient<ICampaignManagementService>(
_authorizationData,
apiEnvironment
);
var getCampaignRequest = new GetCampaignsByIdsRequest
{
AccountId = <the-accountid-is-here>,
CampaignIds = new List<long>() { <the-campaignid-is-here> }
};
var getCampaignResponse = (await _campaignManagementService.CallAsync((s, r) => s.GetCampaignsByIdsAsync(r), getCampaignRequest));
When I run this, an exception is thrown on the last line that reports:
"Invalid client data. Check the SOAP fault details for more information."
Unfortunately, using the API, I'm not seeing the details of the actual response. Is there a way to get at this info? (Short of rewriting the whole thing without using the API?)
Edit:
Thanks to Panagiotis Kanavos I found the solution i think. This is for a different api (reporting) but it should look the same.
The exception has an InnerException that is of type System.ServiceModel.FaultException<Microsoft.BingAds.V13.Reporting.AdApiFaultDetail> or something similar. This has the Detail property with additional information:
Original post:
Can't seem to be able to easily inspect the SOAP request. But you can sniff the request with Fiddler classic The classic version is free.
I would like to make a successful API call, then print the values in order to see if it works. My main goal is to analyze the data, after I can make a successful API call, and build a systematic strategy for trading.
System.Net.Http.HttpRequestException: "Response status code does not indicate success: 403 (Forbidden)
namespace marketstacktest
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
var options = Options.Create(new MarketstackOptions() { ApiToken = "secretTokenHere" });
var marketstackService = new MarketstackService(options, NullLogger<MarketstackService>.Instance);
var appleSymbol = "AAPL";
var fromDate = DateTime.Now.AddDays(-200);
var toDate = DateTime.Now;
//error at the await System.Net.Http.HttpRequestException: "Response status code does not indicate success: 403 (Forbidden)."
List<Marketstack.Entities.Stocks.StockBar> stock = await marketstackService.GetStockEodBars(appleSymbol, fromDate, toDate);
foreach (var stock_i in stock)
{
Console.WriteLine($"close: {stock_i.Close}");
}
}
}
}
In the API manual, which is directly linked from the github, it gives information about all of the error codes. The relevant ones here are these two:
Code
Type
Description
403
https_access_restricted
HTTPS access is not supported on the current subscription plan.
403
function_access_restricted
The given API endpoint is not supported on the current subscription plan.
Their class library on github is just wrapping a json REST api. Every call to the API is just an http request, returning data as json objects. The 403 error indicates that your request was accepted as a valid request, but intentionally rejected by the server for some reason. And according to the docs, the error was because your account is not allowed access to either https or to the type of request.
Their free-tier subscription only includes end-of-day data, which is what you requested, so it wouldn't make sense for that not to be allowed. So, your app is almost certainly making an https call.
I went to the examples at the very beginning of their quick start guide, and chose the end-of-day example to match your app, and clicked on the link. It worked, and gave a bunch of json records. But, the request they made was using 'http' not 'https'.
Changing the requst to 'https' elicited a 403 response with this content (formatted for readability):
{
"error":
{
"code": "https_access_restricted",
"message": "Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."
}
}
At this point we have enough to be almost certain that this is your issue. The final thing is to go look up how to turn https requests off in their class library. To avoid having to go through the code, I checked the help at the bottom of the page one more time, and found this (formatted for readability):
var options = Options.Create(new MarketstackOptions(){
ApiToken = apiKey,
MaxRequestsPerSecond = 3,
Https = true
});
Welp. This should probably be in their first example, since that's what people are most likely to try first, but it's not. So, to stop trying to make http requests, you just need to set the Https option to false in your code. You just need to add that to the options in your code, like so:
var options = Options.Create(new MarketstackOptions(){
ApiToken = "secretTokenHere",
Https = false
});
I will leave the testing to you, but from the browser test, we know that the request should work, unless there's a bug in their library. Given the information that was available, this is almost certainly the issue.
I am trying to integrate my GraphQL Web API with AppSync. But I am getting the following error
"errorType": "MappingTemplate",
"message": "Template transformation yielded an empty response."
My Data Source HTTP end Point is : https://mybooking123.com
My Query is:
mutation
{
Booking(ID:111,BusNumber:"AAAA1", comment:"None")
{
BusNumber
PassngerName
TravelDate
TravelTime
ValidityDate
ValidaityTime
ErrorCode
}
}: [BookingResponse]
Schema
type Mutation {
Booking(
ID: Int!,
BusNumber: String,
comment: String
): [BookingResponse]
}
type BookingResponse
{
BusNumber: String
PassngerName: String
BookingDate: String
BookingTime: String
ValidityDate: String
ValidaityTime: String
ErrorCode: Int
}
AppSync - Request Mapping Template
{
"version": "2018-05-29",
"method": "POST",
"resourcePath": "/GraphQL",
"params":{
"query":$util.toJson($ctx.args),
"headers": {
"Authorization": "$ctx.request.headers.Authorization"
}
}
}
AppSync - Response Mapping Template
## Raise a GraphQL field error in case of a datasource invocation error
#if($ctx.error)
$util.error($ctx.error.message, $ctx.error.type)
#end
## If the response is not 200 then return an error. Else return the body **
#if($ctx.result.statusCode == 200)
#set($body = $util.parseJson($ctx.result.body))
$util.toJson($body) ##make it $body.data depending on the return on your rest api
#else
$utils.appendError($ctx.result.body, "$ctx.result.statusCode")
#end
My GraphQL API is working with out AppSync. But I want to implement AppSync to access the GraphQL API. I am not sure what's wrong with the template mapping. Thanks for your help.
The problem can be with the $utils.appendError VTL method (line 10 of the Response Mapping Template).
Based on your Response mapping template, if there is an error in the Velocity parsing, AppSync will throw an error (line 2).
If there is no error, the Velocity parser will evaluate the response ($ctx.result) and send back the body if the statusCode is equal to 200. So far so good. The problem is if the statusCode is different from 200 (line 9).
In that case, AppSync should also throw an error. But you are using the $util.appendError. In that case, VTL will add error information to the context and will keep working to generate the result template. But because it does not do anything after this step, the generated template is empty (Template transformation yielded an empty response.).
the info from AppSync Resolver Mapping Util docs:
$util.appendError(String)
Appends a custom error. This can be used in request or response mapping templates if the template detects an error with the request or with the invocation result. Unlike $util.error(String), the template evaluation will not be interrupted, so that data can be returned to the caller.
In GraphQL is possible to have a response that has a part that was successful and a part that was an error. That happens because the response probably is coming from two different resolvers. If one of them worked in the other doesn't, you can get the response both responses in the final GraphQL response. In that scenario, AppSync will add the success response to the expected GraphQL field and add the error to the context.
To solve your issue, instead of using $util.appendError use $util.error in line 10. With that, if your call failed, AppSync will add the error information and halt the VLT execution instead of try to perform the next steps to yield the result.
I have a problem loading a 3D model on an online server, the error shown is related to accessing the Forge API, locally works smoothly however when mounted on the server or a website is made marks the following error "Failed to load resource: the server responded with a status of 404 (Not Found)", then "onDocumentLoadFailure() - errorCode:7".
As I comment, what I find stranger is that, locally, it works. Attached the segment of the code where it displays the error.
function getAccessToken() {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", '/api/forge/toke', false); //Address not found
xmlHttp.send(null);
return xmlHttp.responseText;
}
Thank you very much in advance.
Are you sure the code you're running locally and the code you've deployed are really the same?
The getAccessToken function doesn't seem to be correct, for several reasons:
First of all, there seems to be a typo in the URL - shouldn't it be /api/forge/token instead of /api/forge/toke?
More importantly, the HTTP request is asynchronous, meaning that it cannot return the response immediately after calling xmlHttp.send(). You can find more details about the usage of XMLHttpRequest in https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest.
And finally, assuming that the function is passed to Autodesk.Viewing.Initializer options, it should return the token using a callback parameter passed to it (as shown in https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/viewer_basics/initialization/#example).
With that, your getAccessToken should probably look more like this (using the more modern fetch and async/await):
async function getAccessToken(callback) {
const resp = await fetch('/api/forge/token');
const json = await resp.json();
callback(json.access_token, json.expires_in);
}
I've already found the issue. When I make the deploy I have to change the url where the request is made for the public or the name of the domain. For example: mywebsite.com/aplication-name/api/forge/token.
I am trying to use the new TFS/VSTS REST APIs with our on-prem TFS 2015 server, and cannot retrieve test runs as the response fails internal validation.
Using client code like the following:
var connection = new VssConnection(serverUri), credentials);
var client = connection.GetClient<TestManagementHttpClient>();
var runs = await client.GetTestRunsAsync("project", planId:183110);
throws a JsonSerializationException in line 3 with the following message:
Required property 'environmentName' not found in JSON. Pathvalue[0].testEnvironment', line 1, position 582.
which is accurate. Checking the response in Fiddler shows that the testEnvironment property only has an environmentId property, no name. I have uploaded a trimmed sample of the response to this gist.
My question is why does TFS not return this value or alternatively, is there a way to force the API SDK to ignore this validation error?
I can reproduce that issue if includeRunDetails parameter is true. I reported a bug here that you can vote it.
The workaround is that you could set includeRunDetails to false to get test runs without details include, then base on the result (test run id) to get a test run with details that you want.
client.GetTestRunByIdAsync