Sending image as base64_encoded in json_payload on lumen API - json

I am sending image as base64_encoded in JSON_PAYLOAD from front-end AJAX request, on the other side I am using LUMEN API to accept that request, get file and store it in db in field having LONGBLOG type, but problem is that when I dump my API method to see the payload sent by front-end it dumps nothing.
my payload is:
{
data:example_base_64_encoded_file
}
here is api method.
public function upload(Request $request){
dd(request->data);
}
It gives error that calling the undefined object and when dump only dd($request) it dumps null
CORS are already enabled. I also tried to enable content-type as base_64.

Related

The response has been truncated in angular

The communication with the Api Rest server is fine, it returns code 200. The request used is GET, sending authentication parameters by the header. So far there, the problem is in the content of the response, it shows a partial json and an error message that says: The response has been truncated.
I used the same code with other methods and I had no problem. I infer that the problem is because the json that is returning is very large and truncates it.
public getTrialBalanceStatementPeriodwise(reportInput: TrialBalanceReportInput) {
reportInput.periodicReport=1;
return this.http.post('/TrueBooks/rest/reports/trialbalanceperiodwise', reportInput,{responseType:'json'});
}

Request Body issue in Spring Boot PUT Request

I am trying to create a PUT request where admin will be making decision based on some criteria and Verifying or Rejecting a user. I expect this decision in JSON body(Refer to Verification method in below image). But I am confused what json body should I send. I have sent the following JSON body { "REJECTED" }
{ REJECTED }
REJECTED
But everytime, it is returning false in the above method. Please help!!
You are not returning any JSON here - your method type is void.
You need to return something maybe string or response itself.
Using System.out.println(), you are displaying the message on your console only but not sending a response to the server.

angular 4 http get request doesnt subscribe to json response (mongoose result) from api

the http client get request to the api, works I see that a json object is being returned with the command
res.send (data) after finding it in Mongoose.
I understand that httpclient now sends standard json format back from the api, however I don’t understand how to subbscribe to this data on the client side. How do I receive the object that is being send back with res.send.
I added an interface to the get request that sets up the variables that tie in with the json object.
However I can’t get the data nor do I get any failures as if the .subscribe is not being called.
I am using the httpclient docs but somehow I can’t get it to work.
Below the get request that I am using “might not be entirely correct” which works but the obj doesn’t get subscribed to
http.get(url, {params})
.subscribe (data => {console.log(data)});
}
ie. I get no error, which I expect as the log can’t read json format?

Not able to access a string value in aws lambda function from AWS API request

I created a sample AWS lambda function and integrated this function with AWS API.
I have written a post method in API and selected application/JSON whose request integration mapping is as below.
{
'songTitle':"$input.params('songTitle')"
}
songTitle is being sent as parameter (application/JSON) with request to API.
However I am receiving $input.params() as empty.
As I am new to this I have no idea what is the correct way.
Please guide to access these params
I'm not sure if this is your issue, but single quotes are not the same as double quotes in JSON. Anything in the mapping template that isn't escaped with the $ character is written as-is in the actual payload.
Should be:
{
"songTitle":"$input.params('songTitle')"
}
Edit: If that doesn't work, please also test by sending the Content-Type header in the request as application/json. If you don't send Content-Type at all, it should default to application/json mapping template.
In case of reading input parameters from request header part (for request integration mapping)
syntax:
{
'songTitle':"$input.params('songTitle')"
}
If we want to read parameters from request body part we should write as
{
'songTitle':"$input.path('$.songTitle')"`enter code here`
}

How to send json using #RequestBody without using domain object

I am building project REST project with Spring Boot and i come across an issue of sending JSON from client to server.
My Scenerio is i want to send json like this using postman REST client:
{
"test":"success"
}
And want to get this json using this method:
#RequestMapping(value = "/user", method = RequestMethod.POST)
public Map<String, Object> postData(#RequestBody Map map){
log.info("in test Connection method");
return map;
}
I am using above method but it is giving exception.
If it is not possible to process json data with #RequestBody with POST request then is there any other way to get json data with POST request and process that json data?
I have just tested it here and it works fine.
You have to specify the Content-Type header in your POST request though, and set it to application/json. You can easily do this in Postman in the Headers tab.`
Without it you will most likely get an Internal Server Error (500) saying
Content type 'text/plain;charset=UTF-8' not supported