recently I ran into an error every time I try to access the Autodesk Forge API. I haven't made any changes to my code but since last week the line of code shown below throws an error.
var content = (StreamContent)client.GetAsync(url).Result.Content;
The error text is as follows.
An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.
I did some testing and it looks like the following line of code returns 'null'.
var url = wi.Arguments.OutputArguments.First(a => a.Name == "Results").Resource;
So the problem seems to be that my work item is not running properly and not returning a valid output.
My code is very similar to the samples provided by Autodesk and as I said my program was working fine up until last week so I am hoping that someone can help me figure out what is causing this issue.
Related
I want to add exception when a user enters an invalid URL to call the endpoint in Anypoint studio.
Like my default path for calling the API is http://localhost:1234/api/flights, so I want a custom message "Something went wrong!" with a status code of 500 to be shown in an exception when a user enters bad path like http://localhost:1234/24api/flights. I have used APIKit router in this case. Please help me.
Because that is an invalid URI the HTTP Listener and APIKit should be returning a 404 (Not found) status code by default, which is the correct one for this scenario. Returning a 500 status code would be misleading.
I am currently following the mulesoft fundamentals 4 module 5. as i have been following the guide i should be able to Make requests to the API proxy from Exchange. However, every-time i click send i get an Error; Script error. Displaying unprocessed data"
The Error message Below:
Script error. Displaying unprocessed data.
''''''
The image displays the error code
Thank You for your help
This is because the server is unreachable or bad gateway (502).Make sure the implementation URL which you provide to create proxy is working.In my case I have used https instead of http.
I'm writing a API call with Fetch() to download a file from another Domain. The process is: A fetch() method is calling in DomainA to an API in DomainB, then the API returns the response with location in repsonse's header, the location is an url of DomainC.
In Chrome and IE, it works well. Based on the Network Inspection, we can see 3 http requests here.
A. An OPTIONS request to the API, the response Status code 200;
B. An GET request to the API, and the response status code is 302 and
in the response Header, location property contains the target file
location (http url).
C. A request to the target file location to download the file.
But in Firefox and Edge, we can only see the request A) and B). Both of their responses are expected. While there is no 3rd request to download the data. Within debugging, we can see an error is thrown in the fetch().catch(error){}, the error is TypeError:
In Firefox:
TypeError: NetworkError when attempting to fetch resource. In Edge:
TypeError: Failed to fetch
I just did some investigation on this issue.
According to Http-redirect fetch, it should work well since CORS is configured correctly. I guess Firefox or Edge may implement their native fetch() method which leads an failure here.
Does anyone know what's going on here? Thanks.
I'm presently working on a phx / phoenix API written in Elixir. And I have created a frontend for the API using React.js. However, I'm getting the below error message in the JS console of the browser.
I have successfully created a user using Postman, so I'm 99% sure the error isn't with the phx project, but rather somewhere with the React project.
I have both the frontend and backend hosted on github. And a .env file will need to be created in the root of the React project with the below line,
REACT_APP_API_URL=http://localhost:4000/api
and was working my way through the following tutorial.
Any and all help would greatly be appreciated.
The output of localStorage.getItem("token") being
eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJVc2VyOjEiLCJleHAiOjE0ODcyODI4ODcsImlhdCI6MTQ4NDY5MDg4NywiaXNzIjoiUGhvZW5peENoYXQiLCJqdGkiOiIwNzFlYzgwYi0wZmYzLTQyYzgtODA3Mi1kNzViZmVhZTg4NWEiLCJwZW0iOnt9LCJzdWIiOiJVc2VyOjEiLCJ0eXAiOiJhY2Nlc3MifQ.NsuqH50HooK8vjFfHtPH9iXSykZ9oYA0ul4b_C5fQtpu_zFvNNy-skcv9HI2i25X-NlB-9xOr-xzh2abnrpYUw
suggests that for some reason, the app stored the token without passing it through JSON.stringify, and calling JSON.parse on this string throws the Unexpected token e error, as expected.
I did not see any localStorage.setItem without JSON.stringify in the current code, so the token was probably stored like that in a previous version of the app. You should try clearing it manually and logging in again.
When we get the non-JSON response, we get such error..
To avoid such error, mention the responseType: Text in your api endpoint call.
This will work,
return this.http.post(`${environment.apiUrl}/login`, user, {responseType: 'text'});
This will not work(If you mention type),
return this.http.post<string>(`${environment.apiUrl}/login`, user, {responseType: 'text'});
This error message usually means you're getting a non-JSON response. If you look at the raw response in the Network tab of your debugger, you should be able to see what you're getting back from the server.
I'm making a request to an authorized Instagram account to display images on a site. Originally, I was running into No 'Access-Control-Allow-Origin' when using Angular's $http.get(....
From Matt's answer in this question, It seems that I can use getJSON, or Angular $http.jsonp, to bypass this issue. That Guy's answer also says "JSONP is really a simply trick to overcome XMLHttpRequest same domain policy".
So, I'm no longer getting that problem, and am getting a json payload:
{"pagination":{"next_url":"https:\/\/api.instagram.com... etc
But am getting a very ambiguous error:
Uncaught SyntaxError: Unexpected token :
This is a response from the Instagram API, so I'm not sure why there'd be a syntax error on the inbound json. Also, It's hard to locate the error since the jsonp response is all on a single line... where the error is reported.
The preview shows that I'm getting a full payload:
I found the issue. Unfortunately there are no JavaScript libraries to help with this, but in the Instagram API docs, for JSONP you can wrap the response with a callback so that the json payload will be wrapped in <script> tags (more info on jsonp here), therefore not blocked by Access Control Allow Origin.
https://api.instagram.com/v1/tags/coffee/media/recent?access_token=ACCESS-TOKEN&callback=callbackFunction
Response:
callbackFunction({
...
});
So, in your http request URI, you add in a callback parameter. Since I am using Angular, their docs for $http.jsonp() requests specify the callback string as "JSON_CALLBACK".
So, my request URL for Angular would be:
$http.jsonp(
'https://api.instagram.com/v1/tags/coffee/media/recent?
access_token=ACCESS-TOKEN&callback=JSON_CALLBACK')
.success(function(data) {...