Hoxton.SR6 with Spring Boot 2.3.0 cause weird content type issue - spring-cloud

When i updated my Spring Boot 2.3.0.RELEASE Application from Hoxton.SR4 to Hoxton.SR6 (the only change), i started facing weird issues with Content Type from various endpoints.
For example, with Hoxton.SR4, any unauthorized endpoint was returning this error:
{
"error": "unauthorized",
"error_description": "Full authentication is required to access this resource"
}
Same authorization server error in Hoxton.SR6 comes in XML
<UnauthorizedException>
<error>unauthorized</error>
<error_description>Full authentication is required to access this resource</error_description>
</UnauthorizedException>
many other endpoints are returning content in XML rather than application/json.
Can someone help with fixing the default content type for Spring Cloud Hoxton.SR6?

Related

All Tags not replicating from SOAP Endpoint while creating REST Service in WSO2 API-Manager

I am trying to create a REST Endpoint from a SOAP Endpoint using WSO2 API Manager(v3.2.0).
Steps are
Launch API Manager
Create API > I have a SOAP Endpoint
Implementation Type : Generate REST APIs, Input Type : WSDL URL
I enter the WSDL URL and system validates it.
I enter the Name of the API, context, version, endpoint URL and select the Business Plan and click on CREATE.
API is created. Now I click on Resources and a specific post method e.g., createContract. In the in-mediation file, all xml tags present in the SOAP endpoint is not reflected properly.
I have tried to add these tags manually as well but it does not reflect in the REST API.
Kindly help!
TID: [-1234] [] [2021-07-29 09:28:14,972] INFO {org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler} - org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler Initialised
TID: [-1234] [] [2021-07-29 09:28:15,120] ERROR {org.apache.synapse.mediators.bsf.ScriptMediator} - {api:admin--FCUBSDEService:v1} The script engine returned an error executing the inlined js script function mediate com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "Jrnl" is not defined. (<Unknown Source>#3) in <Unknown Source> at line number 3
at com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
at java.scripting/javax.script.CompiledScript.eval(CompiledScript.java:89)

Swagger results with `TypeError: Failed to fetch` for .net core RedirectResult

I have .net core WebApi application setup with swagger. An endpoint that responses with RedirectResult is not handled by swagger ui and shown up as Undocumented: TypeError: Failed to fetch
The redirect result itself contains a SAS url to Azure Storage Blob file.
I've tried to call this endpoint with SoapUI and Postman and the actual file appeared in response with application/octet-stream content type
The endpoint is built in format
Task<IActionResult> DownloadDocument([FromRoute] Guid id)
{
...
return Redirect(blobSasUri)
}
There is support for that or even some workaround or I've missed something?

I am unable to access the Driver behavior service API's through any means like from node js, python, and by postman also

I am using one API to get the car probe data by date. This is the API
get method: https://api.ibm.com/driverinsights/datastore/carProbe/dateList?tenant_id=1ce29c2a-d408-4551-b1fd-815cf5810a02
Headers:
accept:application/json
content-type:application/json
Authorization:Basic NEZwMkd5bVc6cEdddHVqc1c1eVJaQVA=
I am getting response as
{
"httpCode": "404",
"httpMessage": "Not Found",
"moreInformation": "The requested URL was not found on this server"
}
the error message on your side says "404 Not Found".
Please check your hostname in the URL of Driver Behavior service.
[Correct]
"https://automotive.internetofthings.ibmcloud.com/driverinsights"
[Incorrect (yours)]
"https://api.ibm.com/driverinsights"
Please refer to official API documentation.
https://developer.ibm.com/api/view/id-261:title-IBM_Watson_IoT_Driver_Behavior#doc

Spring security rest plugin: token based authentiction

I am trying to get successfully integrate Spring security rest plugin
But I am constantly failed,I am using the memcahed for token storage. Config.groovy Setup which I used to implement the plugin is :
//login end point url
grails.plugin.springsecurity.rest.login.active=true
grails.plugin.springsecurity.rest.login.endpointUrl='/api/login'
grails.plugin.springsecurity.rest.login.failureStatusCode='401'
//for memcached
grails.plugin.springsecurity.rest.token.storage.useMemcached=false
grails.plugin.springsecurity.rest.token.storage.memcached.hosts='localhost:11211'
grails.plugin.springsecurity.rest.token.storage.memcached.username=''
grails.plugin.springsecurity.rest.token.storage.memcached.password=''
grails.plugin.springsecurity.rest.token.storage.memcached.expiration=3600
//token generation
grails.plugin.springsecurity.rest.token.generation.useSecureRandom=true
grails.plugin.springsecurity.rest.token.generation.useUUID=false
I making a request on /api/login via Post man rest client with
{
"username": "john.doe",
"password": "dontTellAnybody"
}
json data but it gives me spring security auth page's html in response, Am I doing some wrong configuration?Is there any futher configuration is required.I mentioned that I am using memcache for token storage.Any Idea will be helpfull for me.
Edit: please see the logs file
Edit2 : please check this log file

GWTTestCase - HTMLUnit - No permitted "Access-Control-Allow-Origin"

When running GWTTestCase that call an external Restful service with GWT (Using Restlet-GWT) the app throws the error below.
Error:
Jan 05, 2015 1:24:41 PM com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl runSingleJob
SEVERE: Job run failed with unexpected RuntimeException: Wrapped java.lang.RuntimeException: No permitted "Access-Control-Allow-Origin" header.
net.sourceforge.htmlunit.corejs.javascript.WrappedException: Wrapped java.lang.RuntimeException: No permitted "Access-Control-Allow-Origin" header.
at net.sourceforge.htmlunit.corejs.javascript.Context.throwAsScriptRuntimeEx(Context.java:1889)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:681)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:94)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:603)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: No permitted "Access-Control-Allow-Origin" header.
... 9 more
From my research this seems to be an issue that HTMLUnit would not allow to access Cross-domain, is there a work around with this?
You can add the support of CORS to your application.
A support has been provided in 2.3 release of the Restlet framework (cf http://restlet.com/technical-resources/restlet-framework/guide/2.3/introduction/whats-new/2.3).
If you are using the 2.2 release, and because we won't add this feature to 2.2, you can add the required classes in your own code manually (cf https://github.com/restlet/restlet-framework-java/blob/2.3/modules/org.restlet/src/org/restlet/service/CorsService.java, https://github.com/restlet/restlet-framework-java/blob/2.3/modules/org.restlet/src/org/restlet/engine/application/CorsFilter.java, and https://github.com/restlet/restlet-framework-java/blob/2.3/modules/org.restlet/src/org/restlet/engine/application/CorsResponseHelper.java).
I was stumped by this very same error response but I am not able to refactor the Restlet framework into my client & server codebases.
A couple of tips for handling diagnosis of the problem.
use a proxy or inspect dev tool to record the exact headers within the request and response for both the OPTIONS and GET/POST pairs.
OPTIONS request header "Origin" must match response header "Access-Control-Allow-Origin" exactly. No wildcards. Perhaps write your response to just echo the request like:
response.addHeader("Access-control-allow-origin", request.getHeader("Origin"));
Your request header names must be fully enumerated within the OPTIONS "Access-control-request-headers" header value AND match the "Access-control-Allow-Headers" response header.
Note: that a mismatch in #3 will trigger the same error message as a mismatch in #2.