I am trying to create an RPC that lists departments in a service. However, the endpoint for listing all departments returns an HTTP 404 error if no departments exist. It seems that the 'valid' directive does not work when the status code is greater than 399. Is there a workaround for this?
There is no way to mark a response status greater than 399 as OK. The valid directive serves for the other direction - marking a 200 status as an error. The only thing I can recommend is putting the following error handling code inside your RPC:
"error": {
"404": {
"type": "DataError",
"message": "No departments found. --ServiceName-- marks this case as an error - please switch to the Map mode to save."
}
}
That will at least help the user know what's going on when they try to set up the module input.
Here's what this would look like inside a Scenario.
Related
I am trying to fetch users details from linkedIn api. After generating accesstoken I can get my details from linkedIn api but I want to get other members details. How to get this work? please help me.
I have tried the solutions according to the documentation.
As per the documentation we have to sent a get request to the GET https://api.linkedin.com/rest/people/(id:{person ID}) to Retrieve Other Member's Profile. When I am sending the get request it is showing me
data: {
code: 'VERSION_MISSING',
message: 'A version must be present. Please specify a version by adding the LinkedIn-Version header.'
}
this error. after searching the documentation I found that there is a note saying
in order to make the sample calls above succeed, you must include
X-RestLi-Protocol-Version:2.0.0 in your request header.
I have added that to and still getting the error.
I experienced the same issue. After some browsing this works for me:
Use https://api.linkedin.com/v2/me instead of https://api.linkedin.com/rest/me
You need to pass the version number like this: LinkedIn-Version: 202210. It worked for me without changing /rest to /v2. More info here: Introducing API Versioning and New Content APIs.
I had the same problem.
As the error says, I tried using LinkedIn-Version as the header key and got:
{
"code": "INVALID_VERSION",
"message": "API versions should have date format as YYYYMM or YYYYMM.RR where RR is the revision"
}
With the header value being: 2.0.0
So I tried sending as value: 202201.01 ==> YYYY=2022, MM=01, RR=01
YYYY: year
MM: month
RR: revision
Obtaining:
{
"code": "NONEXISTENT_VERSION",
"message": "Requested version 20220101 is not active"
}
Trying some different dates and revision codes, I got to value = 202204.01 that gave me:
{
"serviceErrorCode": 100,
"code": "ACCESS_DENIED",
"message": "Not enough permissions to access: me.GET.20220401"
}
I'm also facing the same issue but you can use this
https://api.linkedin.com/v2/me
and it will work
This version worked for me: 202204.01
Then I got:
"code": "EMPTY_ACCESS_TOKEN",
"message": "Empty oauth2 access token"
Which I think can be fixed by getting the access token by implementing the 3-legged OAuth. I have successfully implemented that for getting someone's profile but I am doing this for getting org info
i'm trying to check if a pdf file exists on the server with an HTTP get request,for that i am testing if the status code returned by the server's response is different then 200, the problem is that i always get status code 200 and statusText "OK".
here's my Service class
getPdf(year: number,type: number, num: number): boolean{
this.http.get('http://localhost:4200/app/pdfs/'+year+'/'+type+'/'+num+'.pdf')
.subscribe(data => console.log(data));
return true;
}
in my component i have this code :
ngOnInit(){
this.pdfService.getPdf(2016,71015,1275);
}
and that's the result i get in Chrome dev tools console
any ideas of why that is happening and how i can check the existance of a file if this method is not applicable?
I think your server is redirecting some or all requests for assets not found to your main page. It is somewhat common for a single page app. You need to update your server configurations to make it return a not found response for some folders at least.
In Apigee, can fault handling - specifying a FaultRule and a RaiseFault policy be used to handle and provide a custom message for:
{
"fault": {
"faultstring": "Not Found",
"detail": {
"errorcode": "CLASSIFICATION_FAILURE"
}
}
}
If this can be done, should the 'Condition' for the fault rule be 'fault.name = "CLASSIFICATION_FAILURE"'? I tried this and it is not working.
CLASSIFICATION_FAILURE is a system level failure to find an API Proxy for the given URL/URI. The request will not even reach the API proxy(hence the policies) - which is the precise complaint by the system.
So you do not want to handle an error like that.
Another way to approach this case is to have a catch all API proxy with basepath /** which will be invoked when there is no specific URL match. You can generate a custom message in this proxy - this can be the message you wanted to send across in case of classification failure.
Srikanth's answer on 30/05/2014 is only partially correct. Using a basepath /** did not work for us. Instead, we had to create an api proxy with basepath = /
Inside the proxy, we defined a RaiseFault in Preflow and that was it.
I have an Apigee proxy that has two resources (/resource1 and /resource2). If tried to access /resource3. How do I return a 404 error instead of the Apigee default fault?
Apigee displays the below fault string:
{
"fault": {
"faultstring": "The Service is temporarily unavailable",
"detail": {
"errorcode": "messaging.adaptors.http.flow.ServiceUnavailable"
}
}
}
Thanks
Currently the way flows work in apigee this way - It parses through your default.xml (in proxy) and tries to match your request with one of the flow either through the path-suffix like "/resource1, /resource2" or VERB or any other condition you might have. If it does not find any matching condition, it throws the error like above.
You can add a special flow which will be kicked in if the condition matches none of the valid flows you have. You can add a raisefault policy in that flow and add a custom error response through that flow.
A better solution is to:
be sure to define something in the base path of all Proxy APIs
create an additional Proxy API called "catchall" with a base path of "/" and with just a Raise fault throwing a 404
Apigee execute Proxy APIs from longest Base Path to shortest; the catchall will run last and always throw back a 404
I just want to clarify Vinit's answer. Vinit said:
If it does not find any matching condition, it throws the error like above.
Actually, if no matching flow condition is found, the request will still be sent through to the backend. The error you mentioned:
{
"fault": {
"faultstring": "The Service is temporarily unavailable",
"detail": {
"errorcode": "messaging.adaptors.http.flow.ServiceUnavailable"
}
}
}
was returned after attempting to connect to the backend without matching a flow.
Vinit's solution to raise a fault to create the 404 is the best solution for your requirements.
In some cases, however, it is appropriate to pass all traffic through to the backend (for example, if you don't need to modify each resource at the Apigee layer, and you don't want to have to update your Apigee proxy every time you add a new API resource). Not matching any flow condition would work fine for that use case.
I have an Open Graph achievement at the following URL:
http://rinth.bucket1.s3.amazonaws.com/Achievements_LOCAL/Achievement1.html
When I attempt to register it, I get a response of: status code 400: OAuth "Facebook Platform" "invalid_request" "(#3502) Object at achievement URL is not of type game.achievement"
When I bring up the debug tool to have it validate the HTML:
http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Frinth.bucket1.s3.amazonaws.com%2FAchievements_LOCAL%2FAchievement1.html
I get the following errors:
Object Base Domain Not Allowed: Object at URL 'http://rinth.bucket1.s3.amazonaws.com/Achievements_LOCAL/Achievement1.html' of type 'game.achievement' is invalid because the domain 'rinth.bucket1.s3.amazonaws.com' is not allowed for the specified application id '217132388329112'.
Missing Required Property: The og:url property is required, but not present.
Missing Required Property: The og:type property is required, but not present.
Missing Required Property: The og:title property is required, but not present.
I verified that this domain IS allowed by our application. Just in case, I also tried the entire process using a different domain (which resulted in the exact same error).
The graph URL at the bottom of the debug tool prints the following:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException"
}
}
Any ideas on what I'm doing wrong?
To fix this problem you have to add "rinth.bucket1.s3.amazonaws.com" to the list of app domains in your application settings.
This security measure is there so that you can only access achievements from domains and applications that you specify.