Response code is 200 with error count 0 but response body is null.
PostMan Request: i hit the api from postman with this request body.
{"body": {
"distance": 3466567.8,
"latitude": 45.7,
"longitude": 80.7}}
Postman response: I got this reponse on postman.
"requestId": "LME2206071048390000193004",
"msgId": "LME2206071048390000191004",
"accDate": null,
"startDateTime": [
2022,
6,
7,
10,
48,
39,
100000000
],
"locale": "zh_CN",
"routeInfo": "LME"
.......................
Now if i hit the same API with same request body from the JMeter, i got the below mentioned response.
{
"msgId": null,
"source": null,
"locale": null,
"body": null,
"userId": null,
"uri": null,
"accDate": null,
"startDateTime": null,
"requestId": null,
"msgCd": "SYS00001",
"msgInfo": null}
................
Can anyone help me how to resolve this issue.
We cannot "help me how to resolve this issue" unless you share the Postman and JMeter's HTTP Request sampler configurations
It might be the case you forgot something obvious, i.e. sending a relevant Content-Type header
In general if your request works fine in Postman you can just record it using JMeter's HTTP(S) Test Script Recorder
Start HTTP(S) Test Script Recorder (it's better to use Recording Template for this)
Import JMeter's certificate into Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
That's it, JMeter should intercept the request and generate the relevant HTTP Request sampler and friends so you can replay it with increased load
More information: How to Convert Your Postman API Tests to JMeter for Scaling
Above mentioned Issue is resolved.
The main issue was the order of the fields in the request body.
I was sending this request from postman and it was working fine.
{ "body": {
"distance": 3466567.8,
"latitude": 45.7,
"longitude": 80.7
}}
And when i send this same request from jmeter it was not working fine. i was getting null values in the fields of response body. Then i realized and change the order of fields in the request body as according to my business logic and it works.
{
"body": {
"latitude": 45.7,
"longitude": 80.7,
"distance": 3466567.8
}}
Related
I want to update test case outcome status in azure test plans. How can I do this?
I found only how to get info about test plans but without update per test case.
I want to update test case outcome status in azure test plans. How can I do this?
When you manually update the test case outcome status in azure test plans, you could go to the test run and select more options:
And if you want update the test case outcome states with REST API, you could try to use following REST API Results - Update:
PATCH https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/results?api-version=6.0
Request Body:
[
{
"id": 100000,
"state": "Completed",
"comment": "Website theme is looking good",
"associatedBugs": [
{
"id": 30
}
]
},
{
"id": 100001,
"state": "Completed",
"comment": "Website links are failing because of incorrect container id",
"failureType": "Known Issue"
}
]
with above result API, it's require OAuth-2 authentication. So, unable to make update the test case status not with bearer token or signing information in postman.
I'm trying to send a POST request using InteliJ's HTTP client and I'm not receiving it correctly.
I want to send an object and a file in the request, and receive in a Spring Boot's controller as a Request Body parameter.
This is the request:
POST http://localhost:7000/api/reports/annex/save/307
Content-Type: application/json
{
"annex": {
"id": "",
"reportId": "307",
"title": "TEST FILE",
"description": "TEST DESCRIPTION",
"creationDate": "",
"document_path": ""
},
"file": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABkAGQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDxyiiiv3E8wKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//Z"
}
And this is my controller receiving data:
As you see, the object annex is correctly received, but File object is NULL.
Someone knows whats wrong with the request?
Thanks!
We used Spring Cloud Config version 2.1 and it worked.
We updated to Spring Cloud Config 2.2, and now it does not work.
More details are
https://github.com/spring-cloud/spring-cloud-config/issues/1599
I reported the issue to accelerate the process as well, or maybe it is not an issue. I do not know, so I am asking you to help.
Our config file: python-service.yml
resources:
- resource1
- resource2
newResources: []
As I learned, Spring Cloud config client makes requests to fetch configuration, and it passes header
Accept: application/vnd.spring-cloud.config-server.v2+json.
In Spring Cloud config v 2.1
Note, Spring Cloud version 2.1 does not send such header; instead, it sends Accept: application/json
HTTP http://localhost:8888/python-service/dev
Accept: application/vnd.spring-cloud.config-server.v2+json
Returns
{
"name": "python-service",
"profiles": [
"dev"
],
"label": null,
"version": null,
"state": null,
"propertySources": [
{
"name": "file:/configuration/python-service.yml",
"source": {
"resources[0]": "resource1",
"resources[1]": "resource2",
"newResources": []
}
}
]
}
However, it Spring Cloud Config v 2.2, it fails
{
"timestamp": "2020-04-24T08:38:19.803+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Could not construct context for config=python-service profile=dev label=null includeOrigin=true; nested exception is java.lang.NullPointerException",
"path": "/python-service/dev"
}
The funny thing is that there is no exception log output in config-service logs!
If I remove the accept header, I will get (version 2.2)
{
"name": "python-service",
"profiles": [
"dev"
],
"label": null,
"version": null,
"state": null,
"propertySources": [
{
"name": "file:/configuration/python-service.yml",
"source": {
"resources[0]": "resource1",
"resources[1]": "resource2",
"newResources": ""
}
}
]
}
Here, why "newResources": "" became an empty String, if it is expected to be an empty array - another question.
To sum up
1) How to use empty array in Spring Cloud config.
2) Why there is no log message about the NPE in Spring config-service logs.
3) Without the accept header, why "newResources": "" became an empty String, if I expected an empty array.
As for now, I can remove empty array from my config, but it is very scary because our config is used in many services! This breaks backward compatibility.
It turns out, it is a bug in Spring Boot.
https://github.com/spring-cloud/spring-cloud-config/issues/1572#issuecomment-620496235
https://github.com/spring-projects/spring-boot/issues/20506
Possible options:
1) Wait until it is fixed and update libraries.
2) What we did. We replaced empty array with empty element.
newResources:
anotherField: value
alternatively, use null. However, make sure, your code can handle it. Also, emptyArray can be treated as an emptyString. I found this out in debugger.
i am trying to use google api explorer to first try to insert an object to google cloud storage.
the request looks like
POST https://www.googleapis.com/storage/v1/b/visionapibucket/o?key={YOUR_API_KEY}
{
"contentType": "image/jpeg",
"uploadType": "media",
"path": "/upload/storage/v1/b/visionapibucket/o"
}
but i see the error as
400 HTTP/2.0 400
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required"
},
{
"domain": "global",
"reason": "wrongUrlForUpload",
"message": "Upload requests must include an uploadType URL parameter and a URL path beginning with /upload/",
"extendedHelp": "https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload"
}
],
"code": 400,
"message": "Required"
}
}
not sure what i am missing. please advise
Looks like a bug on the website. It doesn't seem like the explorer supports media.
The request it generated looks like:
POST https://www.googleapis.com/storage/v1/b/visionapibucket/o?key={YOUR_API_KEY}
But a proper upload request would look like:
POST https://www.googleapis.com/upload/storage/v1/b/visionapibucket/o?key={YOUR_API_KEY}&uploadType=media&name=myfile.jpeg
You'll also want to include a "Content-Type" header specifying that it's a JPEG image.
There's a guide on the various ways to upload objects using the JSON API here. The specific type you're looking for is like a simple upload.
I have to post json to api_url for login.
{
"username":"testre","password":"password"
}
When I use postman to check this api, it reply successful authentication like below.
{
"status": "success",
"code": 200,
"message": "username, password validated.",
"data": [
{
"password": "password",
"username": "testre"
}
],
"links": [
{
"rel": "self",
"link": "http://localhost:2222/pizza-shefu/api/v1.0/customers/login/"
},
{
"rel": "profile",
"link": "http://localhost:2222/pizza-shefu/api/v1.0/customers/testre"
}
]
}
For an unauthorized json like below.
{
"status": "unauthorized",
"code": 401,
"errorMessage": "HTTP_UNAUTHORIZED",
"description": "credentials provided are not authorized."
}
Previously I code to retrieve it using java. But now I want to refactor it using RestTemplate in spring. The problem is every example I read is written for fixed number of variables https://spring.io/guides/gs/consuming-rest/. Here I get different numbers of variable according to the login success status. I am new to spring so I'm confused in creating the class for login reply which we get from rest template. (Such as this in the example Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class); But I need to return a json object). I couldn't figure out how to write the RestTemplate part.
As suggested by #Andreas:
Add the superset of all fields for all possible responses
Identify the set of fields that are mandatory for every response and make them required
Make the rest of the fields as optional
Upon receveiving a response, check the status code and implement your logic accordingly.
If you are using Jackson for Deserialization, all fields are optional by default (see this question)