The requested captchaStyle 'yourFirstCaptchaStyle' is not defined in the botdetect.xml - spring

I use angular-captcha with angular frontend and spring backend.
I did all the steps defined here but when I call
my-api-endpoint/simple-captcha-endpoint?get=html&c=yourFirstCaptchaStyle ws
it gives me the following error
{ "timestamp": "2021-02-08T00:37:14.011+0000", "status": 400, "error":
"Bad Request", "message": "The requested captchaStyle
'yourFirstCaptchaStyle' is not defined in the botdetect.xml!", "path":
"//simple-captcha-endpoint" }
here is my botdetect.xml file content :
<?xml version="1.0" encoding="UTF-8"?>
<botdetect xmlns="https://captcha.com/schema/java"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://captcha.com/schema/java
https://captcha.com/schema/java/botdetect-4.0.beta3.7.xsd">
<captchaStyles>
<captchaStyle>
<name>yourFirstCaptchaStyle</name>
<userInputID>yourFirstCaptchaUserInput</userInputID>
</captchaStyle>
</captchaStyles>
</botdetect>
I dont know why I get this error just when working on https domain, but not on http://localhost
did I miss something ? thanks in advance

"BDC_configFileLocation", "/WEB-INF/classes/botdetect.xml");
The path /WEB-INF/classes/botdetect.xml worked for me

Related

Getting too many request error in Microsoft calendar graph api (429 error code)

error": {
"code": "ExtensionError",
"message": "Operation: Read; Exception: [Status Code: 429; Reason: Resource 'OData_GetSubscription__UserMailbox_f' has reached limit of '250'. Please retry after '2/17/2022 3:53:22 PM']",
}
how can I resolve this error

how could set content-type in magento web api?

I build simple web api and it returns the error "message": "Content-Type header is invalid." how could I resolve it please guide me.
under Magento/SamplePaymentGateway/etc my webapi is
<?xml version="1.0" ?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route method="GET" url="/V1/cevnn/post">
<service class="Magento\SamplePaymentGateway\Api\PostManagementInterface" method="getPost"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>
Magento/SamplePaymentGateway/Api is PostManagementInterface.php file
<?php
namespace Magento\SamplePaymentGateway\Api;
interface PostManagementInterface {
public function getPost($param);
}
and under Mangento/SamplePaymentGateway/Model there is PostManagement.php file
<?php
namespace Magento\SamplePaymentGateway\Model;
class PostManagement {
public function getPost($param)
{
return 'api GET return the $param ' . $param;
}
}
when I call it through this url http://127.0.0.1/project-community-edition/rest/V1/cevnn/post?param=ali.
it returns the following error {
"message": "Content-Type header is invalid."
}
please guide me how could I fix it.
Dependency Injection configuration is missing.
In order to tell Magento which class to use for interface Magento\SamplePaymentGateway\Api\PostManagementInterface, you must add it in your di.xml file :
<preference for="Magento\SamplePaymentGateway\Api\PostManagementInterface" type="Magento\SamplePaymentGateway\Model\PostManagement"/>

How to set a base url in a springboot graphql app

How can we set a base url in springboot graphql-server app .
By default the graphiql api-console opens on http://localhost:8080/graphiql
Trying to access http://localhost:8080 through postman with a post -query as below :
{
bookings {
name
}
}
gives an error saying :
{
"timestamp": 1549913598497,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/"
}
Q1 what should be the path to the server i should be using to invoke it.
Q2 is there a way to provide a custom base path something loke http://localhost:8080/service/api/query
Usually the server path for graphql endpoints is at http://localhost:8080/graphql. If not just inspect the network tab on your browser when you run a query on your GraphiQL interface, it will run the query on the api endpoint.
In order to change the base path you would need to change application.properties into something like:
graphql.servlet.mapping: /service/api/query
graphiql.mapping: /graphiql
graphiql.endpoint: /service/api/query
If you are using Spring Boot Property file you can change the base url like below:
spring.graphql.path=/service/api/query
Example:
When I changed the base url like below.:
spring.graphql.path=/api/projects/graphql
It reflected like below in console:
2022-11-05 08:58:14.964 INFO 17336 --- [ main] s.b.a.g.s.GraphQlWebMvcAutoConfiguration : GraphQL endpoint HTTP POST /api/projects/graphql
More can be found at below official document:
https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#appendix.application-properties.web

Error executing “PutObject” on AWS

I am trying to read .png file from storage path of laravel and upload the same into amazon s3, but i'm getting this below issue:
{
"code": 422,
"status": "error",
"data": {
"exception": "Error executing \"PutObject\" on \"https://s3.amazonaws.com/mrxmms/123/12345_ach.png\"; AWS HTTP error:
count(): Parameter must be an array or an object that implements
Countable"
},
"message": "Unprocessable Entity" }
Here is my sample code:
$dir = storage_path('uploads'); $image_val = $dir. '/'
."product.png";
$image_load =
Storage::disk('s3')->put("123/12345.png",file_get_contents($image_val));
Can someone please help me? Thanks in advance!!
This issue hit me recently when using Guzzle in version 6.2.1 and AWS SDK in version 3.*
Updating Guzzle to 6.3.* solved the issue for me.
composer require guzzlehttp/guzzle:6.3.*
Hope that helps.

Unable to map the error getting from the application deployed using lambda function

I am having springboot application deployed using a lambda function. Please find the below sample.
Controller
#RequestMapping(method = RequestMethod.GET, value = "/bugnlow/findByRegionId/{regionId}", produces = "application/json")
public ResponseEntity<List<Bunglow>> findAllBunglowsByRegionId(#PathVariable int regionId, #RequestParam int page, #RequestParam int size) {
Page<Bunglow> bunglows = bunglowsService.findAllBunglowsByRegionId(regionId, page, size);
if (bunglows.getContent().size() == 0){
return ResponseEntity.notFound().build();
}
return ResponseEntity.ok(bunglows.getContent());
}
Service
if the "regionid" is invalid, I am throwing a runtime exception that contains message "region id is invalid".
throw new RuntimeException(Constant.INVALID_REGION_ID);
I am getting the below response when testing it locally by sending the invalid region id.
[1]{
"timestamp": 1519577956092,
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.RuntimeException",
"message": "Region Id is invalid",
"path": "/***/bugnlow/findByRegionId/343333"
}
I deployed above application AWS using lambda function. When I send the request from the AWS API gateway to the deployed application I am getting the below error with Amazon response headers.
[2] Request: /bugnlow/findByRegionId/342324?page=0&size=5 Status: 500 Latency: 166 ms Response Body
{ "message": "Internal server error" }
In the particular endpoint, integration responses have already configured for Error 500. But didn't use a template configuring the content-type as application/json.
I able to get the localized error by setting it in the controller class with
ResponseEntity<?>
But then the List Bunglow not display as the example response value in Swagger UI.
I need to get exact response[1] from the AWS console. How to do it.
Instead of error 500, how can I send the "Region id is invalid" with the Http status 400 (bad request).
It's a great help, if someone can help me on this.
Thanks
I able to resolve my problem by creating a class with
#ControllerAdvice
and handle the Exception using
#ExceptionHandler
Each point I need to validate and respond the error, I created an custom Exception "BunglowCustomExceptionResponse" and catch the exception in the Advice class "BunglowControllerAdvice". Then send the response with the exception message with bad request response as below.
#ControllerAdvice
public class BunglowControllerAdvice {
#ExceptionHandler
public ResponseEntity handleCustomBunglowException(Exception e){
logger.info("***Exception occurred :" + e.getLocalizedMessage());
return new ResponseEntity<BunglowCustomExceptionResponse>(new
BunglowCustomExceptionResponse(e.getLocalizedMessage()), HttpStatus.BAD_REQUEST);
}
}
Then, I able to get the expected response similar to below with bad request status code 400.
{"responseMessage": "error message"}
I don't know this is the best way but able to resolve my problem. Anyway, thanks a lot for your time who viewed this and tried to help me.

Resources