Request Body issue in Spring Boot PUT Request - json

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.

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'});
}

Beego get response body in middleware after processing

I have to append parameter in JSON response after request processing is completed and before sending. I can do in after exec filter. Here I defined filter like this,
beego.InsertFilter("*", beego.AfterExec, AddRequestAfterExec, false)
Now in this AddRequestAfterExec method, I am unable to read JSON response. I need to read JSON response and add parameter to it. I searched many things, but did not find any thing useful. So far I have left it empty.
func AddRequestAfterExec(c *context.Context) {}
Can anybody help, how to read Response in this function and modify it?
Also I am sending response from API controller like this
authController.ServeJSON()

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`
}

Crawling: Difference between "query string parameter" and "request payload"

I am trying to crawl a ajax site using Scrapy, the url is http://www.target.com/p/bounty-select-a-size-white-paper-towels-12-mega-rolls/-/A-14920157#prodSlot=medium_1_2&term=bounty
My goal is to get the store id. I did that by checking all the XHR request in chrome developer tool and find the one with name ("v1?request_type=availability&key=.....") to be the one I want.
My questions are:
In developer tool, there is "Query string parameter" which seems to be the part after ? of the request url. There is also Request Payload section, which is a json.
So which one should I use to send to the server? If i need request payload, how can I send a json file?
when i send the whole url to get json:
https://api.target.com/available_to_promise_aggregator/v1?request_type=availability&key=q0jGNkIyuqUTYIlzZKoCfK6ugaNGSP8h
I get "Request method 'GET' not supported", so should I use POST instead or there is something wrong I did?
You must send the query string as part of the URL after a ?, as you guessed.
To include a JSON payload in a request, and send the request as a POST request, use the method and body parameters of the Request class.