django make a request based on the data received - django-queryset

opening a task by uuid
{
"id": 4,
"userInfo": 1,
"uuid": "5a722487",
"title": "Comparing numbers"
}
how to save the id and userinfo to pass to another request without specifying in the url /<'userInfo'>/<'id'> and get recommendations for the received task
[
{
"id": 16,
"userInfo": 1,
"uuid": "1e6a7182",
"title": "The opposite number"
},
{
"id": 11,
"userInfo": 1,
"uuid": "9de9f5d0",
"title": "Your order, please"
},
]

Concider using custom serializer for you objects

Related

JMETER - response assertion -> Response was null

I have checked several options how to validate response and it still not works in my case.
As you can see (Debug sampler), for last_name regex works and I receive some values, but if I want to reuse this response as "Response assertion", test failed, because I receive "Response was null".
JSON Extractor for last_name
Response assertion
Test failed
Also, I would like to count objects in "data", so I used http://jsonpath.herokuapp.com/?path=$..book[0,1] to make sure, the JSON file is correct. But "Debug sampler" shows me nothing :( so test failed again
Count of objects
Result
Any idea how to solve this problem please ?
JSON:
{
"page": 2,
"per_page": 6,
"total": 12,
"total_pages": 2,
"data": [
{
"id": 7,
"email": "michael.lawson#reqres.in",
"first_name": "Michael",
"last_name": "Lawson",
"avatar": "https://reqres.in/img/faces/7-image.jpg"
},
{
"id": 8,
"email": "lindsay.ferguson#reqres.in",
"first_name": "Lindsay",
"last_name": "Ferguson",
"avatar": "https://reqres.in/img/faces/8-image.jpg"
},
{
"id": 9,
"email": "tobias.funke#reqres.in",
"first_name": "Tobias",
"last_name": "Funke",
"avatar": "https://reqres.in/img/faces/9-image.jpg"
},
{
"id": 10,
"email": "byron.fields#reqres.in",
"first_name": "Byron",
"last_name": "Fields",
"avatar": "https://reqres.in/img/faces/10-image.jpg"
},
{
"id": 11,
"email": "george.edwards#reqres.in",
"first_name": "George",
"last_name": "Edwards",
"avatar": "https://reqres.in/img/faces/11-image.jpg"
},
{
"id": 12,
"email": "rachel.howell#reqres.in",
"first_name": "Rachel",
"last_name": "Howell",
"avatar": "https://reqres.in/img/faces/12-image.jpg"
}
],
You need to tick Compute concatenation var in JSON Extractor, otherwise you will get 2 separate JMeter Variables:
lastName_1=Lawson
lastName_2=Ferguson
In addition to point 1 you need to use lastName_ALL in the Response Assertion
You need to switch from Matches to Substring in "Pattern Matching Rules" of the Response assertion
Demo:
More information: How to Use the JSON Extractor For Testing

How to compare JSON data against DB data in JMeter

I want to compare JSON response with DB data in JMeter. Below is Db table structure (Oracle database):
Table Structure
Below is the JSON
{
"page": 2,
"per_page": 6,
"total": 12,
"total_pages": 2,
"data": [
{
"id": 7,
"email": "michael.lawson#reqres.in",
"first_name": "Michael",
"last_name": "Lawson",
"avatar": "https://reqres.in/img/faces/7-image.jpg"
},
{
"id": 8,
"email": "lindsay.ferguson#reqres.in",
"first_name": "Lindsay",
"last_name": "Ferguson",
"avatar": "https://reqres.in/img/faces/8-image.jpg"
},
{
"id": 9,
"email": "tobias.funke#reqres.in",
"first_name": "Tobias",
"last_name": "Funke",
"avatar": "https://reqres.in/img/faces/9-image.jpg"
},
{
"id": 10,
"email": "byron.fields#reqres.in",
"first_name": "Byron",
"last_name": "Fields",
"avatar": "https://reqres.in/img/faces/10-image.jpg"
},
{
"id": 11,
"email": "george.edwards#reqres.in",
"first_name": "George",
"last_name": "Edwards",
"avatar": "https://reqres.in/img/faces/11-image.jpg"
},
{
"id": 12,
"email": "rachel.howell#reqres.in",
"first_name": "Rachel",
"last_name": "Howell",
"avatar": "https://reqres.in/img/faces/12-image.jpg"
}
],
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
Below is the configuration I have made in JMeter
JDBC Request
JSON Extractor
Response Assertion
But I am getting null response:
Assertion Result
what mistake am I making?
I want to compare each cell data with JSON data. For example ID=7 with JSON and ID=9 with JSON and so on.
Is this possible to do this with any scripting language in JMeter, if yes please suggest the code for the same.
There are multiple problems with your setup:
You need to change your SQL query to SELECT ID from HHDIXI.Data, otherwise you will get LAST_NAME entries in the ID variable
You need to change your JSONPath query to $..data[*].id and set "Match No" to -1 otherwise you will get only first ID into idfromAPI variable
Use Debug Sampler and View Results Tree listener combination to see what variables are being generated by the HTTP and JDBC request samplers.
If you want to compare each ID from API to each ID from the DB in one shot the only option is JSR223 Assertion
Example code:
1.upto(vars.get('ID_#') as int, { index ->
def expected = vars.get('ID_' + index)
def actual = vars.get('idfromAPI_' + index)
if (expected != actual) {
AssertionResult.setFailure(true)
AssertionResult.setFailureMessage('Data mismatch, in the database: ' + expected + ', in the API: ' + actual)
}
})
and demo:

Magento 2 REST API : Product Price and Custom Attribute color are not reflecting in response

I am working on Magento2 [v2.4] Product integration use case.
I am creating a Product using REST API [postman] and observed that product price, color attributes are present in Request JSON but those are missing in Response received from Magento.
POST http://localhost/magento2/rest/V1/products
Request:
{
"product": {
"id": "2007",
"sku": "20210004",
"name": "Iphone 4",
"price": "400",
"status": 1,
"extension_attributes": {
"stock_item": {
"qty": 4,
"is_in_stock": "true"
}
},
"custom_attributes": [
{
"attribute_code": "color",
"value": 4
}
]
}
}
Response:
{
"id": 2007,
"sku": "20210004",
"name": "Iphone 4",
"attribute_set_id": 4,
"status": 1,
"visibility": 4,
"extension_attributes": {
"stock_item": {
"item_id": 18,
"product_id": 2007,
"stock_id": 1,
"qty": 4,
"is_in_stock": true,
"is_qty_decimal": false
}
},
"custom_attributes": [
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "url_key",
"value": "iphone-4"
}
]
}
If you look at the request and response payload, you will see that Price and Color are there in request but somehow Magento did not honor those and got missed in response.
If I want to make this work, I had to re-send same payload again. Then I could see Price and Color in response.
Could you please suggest what is the issue here?
This is down to a bug in Magento (https://github.com/magento/magento2/issues/13639).
At the time of writing this should be fixed in 2.4.3. For versions 2.4.2 and lower you can add the following to your payload:
"type_id": "simple"

Cannot retreive virtual card number in test mode via stripe API using Go examples

Trying to follow the example here: https://stripe.com/docs/issuing/cards/virtual
When I add params.AddExpand("number"), no number is returned, yet via the dashboard I was able to see the card numbers. Here's sample code and redacted info for the Req and Resp.
func (ac *appContext) CardRetrieve(id string) *stripe.IssuingCard {
stripe.Key = ac.Config.Stripe.SecretKey
params := stripe.IssuingCardParams{}
params.AddExpand("number")
params.AddExpand("cvc")
ic_num, _ := card.Get(id, &params)
return ic_num
}
Returns:
{
"id": "ic_redacted",
"object": "issuing.card",
"brand": "Visa",
"cancellation_reason": null,
"cardholder": {
"id": "ich_redacted",
"object": "issuing.cardholder",
"billing": {
"address": {
"city": "A Beach",
"country": "US",
"line1": "404 Main St.",
"line2": "Suite #302",
"postal_code": "19001",
"state": "DE"
}
},
"company": null,
"created": 1613338532,
"email": "redacted#notreal.com",
"individual": {
"dob": {
"day": 20,
"month": 10,
"year": 1990
},
"first_name": "User",
"last_name": "Testing",
"verification": {
"document": {
"back": null,
"front": null
}
}
},
"livemode": false,
"metadata": {
},
"name": "User Testing",
"phone_number": "+15165551212",
"requirements": {
"disabled_reason": "under_review",
"past_due": [
]
},
"spending_controls": {
"allowed_categories": [
],
"blocked_categories": [
],
"spending_limits": [
{
"amount": 1,
"categories": [
],
"interval": "daily"
}
],
"spending_limits_currency": "usd"
},
"status": "active",
"type": "individual"
},
"created": 1613338532,
"currency": "usd",
"exp_month": 1,
"exp_year": 2024,
"last4": "0088",
"livemode": false,
"metadata": {
},
"replaced_by": null,
"replacement_for": null,
"replacement_reason": null,
"shipping": null,
"spending_controls": {
"allowed_categories": null,
"blocked_categories": null,
"spending_limits": [
{
"amount": 1,
"categories": [
],
"interval": "daily"
}
],
"spending_limits_currency": "usd"
},
"status": "inactive",
"type": "virtual"
}
What confuses me is the documentation found here:
https://stripe.com/docs/issuing/cards/virtual
It says: You can retrieve both the full unredacted card number and CVC from the API. For security reasons, these fields are only available for virtual cards and will be omitted unless you explicitly request them with the expand property. Additionally, they are only available through the Retrieve a card endpoint. That links to the issue card retrieval end point, but the params defined in the virtual cards example references the CardParams{} struct.
No of the examples show what imported module their aliasing for card to exec card.Get, but it stands to reason given the flow of the documentation that this should be IssuingCardParams{} and that the card alias is referencing: "github.com/stripe/stripe-go/issuing/card"
I also find it strange that we're defining params in the example but not passing it into the card.Get()
Edit:
I went digging through the module and it seems like to get the card details you have to call: details, _ := card.Details(id, params) but I get a 404 when trying to call that. The object returned is actually the right object and I see number and cvc, albeit nil.
I get the following error:
2021/02/15 00:33:06 Request error from Stripe (status 404): {"status":404,"message":"Unrecognized request URL (GET: /v1/issuing/cards/ic_redacted/details). Please see https://stripe.com/docs
So it seems you need to include a /v72 in the import:
"github.com/stripe/stripe-go/v72"
The documentation should be updated to show this and the virtual card example for go should also be updated.

Any limitation on ORDS post API data volume?

I am trying to send a POST request of huge block of JSON to ORDS but always getting 500 - Internal server error.
If I reduce the value to around 2000 the POST API works successfully. I am using a CLOB variable to handle at JSON data inside PL/SQL proc.
What could be wrong ?
[
{
"id": 1382,
"name": "PROD_4",
"description": "Prod_Smart_Name",
"comments": "",
"entity": {
"id": 14,
"entity_name": "data_code"
},
"is_active": 1,
"is_editable": 1,
"is_visible": 1,
"is_used": 4,
"version": 4,
"is_deleted": 0,
"guid": "99044d05f0c74df1ad10c8a6a7b035bc",
"created_by": "swankhad",
"created_date": "04-OCT-17 11.24.08.569000 AM",
"last_modified_by": "runigawa",
"last_modified_date": "25-JUN-19 09.32.54.000000 AM",
"value": [
"23594333089",
"496151500740",
"881996810051",
"5358843633",
"213671772739",
"5348779195",
"5353301001",
"2482690600",
"23599643375",
"23590876041",
"5351247103",
"5358844706",
"23590871124",
"61296679111",
"23590871127",
"23590871128",
"23599103268",
"4930889250",
"213672200260",
"23590876040",
"213672229060",
"53589209680",
"23590876043",
.....
]
}]

Resources