Shopify create customer api is working on postman but not on react native app - react-native

I am working on a Shopify React Native app. I am trying to create a new customer with my app. It is working fine on Postman but not working with my app.
app.
I have also setup my private app on shopify and get all the required credentials from there.
I am posting my code here.
let requestdata =
{
method: 'POST',
headers:
{
'Authorization':'Basic ' + base64.encode('apikey' + ":" +
'password'),
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"customer": {
"first_name": "test",
"last_name": "user",
"email": "testuser#example.com",
"phone": "+15154346011",
"verified_email": true,
"addresses": [
{
"address1": "123 Oak St",
"city": "Ottawa",
"province": "ON",
"phone": "+15154346011",
"zip": "123 ABC",
"last_name": "user",
"first_name": "test",
"country": "CA"
}
]
}}),
};
fetch('https://apikey:password#domainname/admin/api/2020-
04/customers.json', requestdata)
.then(res => {
console.log("resoponse",JSON.stringify(res))
this.setState({
data:res
})
}).catch((err)=>{
console.log(err)
})
}
Here i am also attaching image of response i am getting.
{
"type": "default",
"status": 200,
"ok": true,
"headers": {
"map": {
"referrer-policy": "origin-when-cross-origin",
"cache-control": "no-cache, no-store",
"x-request-id": "fe78c2cb-1f8e-4cbc-815b-7a9aef11145e",
"cf-request-id": "0344067c9e00000f82b3286200000001",
"set-cookie": "_y=5de13f45-35f4-46a9-92f2-502b08a7ab8e; Expires=Fri, 11-Jun-21 08:09:37 GMT; Path=/, request_method=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT, _shopify_y=5de13f45-35f4-46a9-92f2-502b08a7ab8e; Expires=Fri, 11-Jun-21 08:09:37 GMT; Path=/",
"x-shardid": "41",
"x-shopify-login-required": "true",
"expect-ct": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
"x-dc": "gcp-us-east1,gcp-us-central1,gcp-us-central1",
"x-xss-protection": "1; mode=block; report=/xss-report?source%5Baction%5D=login&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fauth&source%5Bsection%5D=admin&source%5Buuid%5D=fe78c2cb-1f8e-4cbc-815b-7a9aef11145e",
"x-sorting-hat-podid": "41",
"content-type": "text/html; charset=utf-8",
"x-frame-options": "DENY",
"x-download-options": "noopen",
"vary": "Accept-Encoding",
"date": "Thu, 11 Jun 2020 08:09:37 GMT",
"nel": "{\"report_to\":\"network-errors\",\"max_age\":2592000,\"failure_fraction\":0.01,\"success_fraction\":0.0001}, {\"report_to\":\"network-errors\",\"max_age\":2592000,\"failure_fraction\":0.01,\"success_fraction\":0.0001}",
"server": "cloudflare",
"x-content-type-options": "nosniff",
"x-shopify-stage": "production",
"report-to": "{\"group\":\"network-errors\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify\"}]}, {\"group\":\"network-errors\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify\"}]}",
"cf-cache-status": "DYNAMIC",
"alt-svc": "h3-27=\":443\"; ma=86400",
"x-shopid": "27371339818",
"shopify-auth-mechanisms": "password",
"content-language": "en",
"cf-ray": "5a19d9da9dab0f82-MXP",
"x-sorting-hat-shopid": "27371339818"
}
},
"url": "https://apikey:password#domainname.myshopify.com/admin/auth/login",
"_bodyInit": {
"_data": {
"size": 1323,
"offset": 0,
"blobId": "0e0582a6-41ee-4cac-a1c4-b651149cc87f",
"__collector": {}
}
},
"_bodyBlob": {
"_data": {
"size": 1323,
"offset": 0,
"blobId": "0e0582a6-41ee-4cac-a1c4-b651149cc87f",
"__collector": {}
}
}
}
And this is the response i am getting from postman:
{
"customer": {
"id": 3028204847146,
"email": "testuser#example.com",
"accepts_marketing": false,
"created_at": "2020-06-14T15:59:02+05:30",
"updated_at": "2020-06-14T15:59:02+05:30",
"first_name": "test",
"last_name": "user",
"orders_count": 0,
"state": "disabled",
"total_spent": "0.00",
"last_order_id": null,
"note": null,
"verified_email": true,
"multipass_identifier": null,
"tax_exempt": false,
"phone": "+15154346011",
"tags": "",
"last_order_name": null,
"currency": "INR",
"addresses": [
{
"id": 3226192674858,
"customer_id": 3028204847146,
"first_name": "test",
"last_name": "user",
"company": null,
"address1": "123 Oak St",
"address2": null,
"city": "Ottawa",
"province": "Ontario",
"country": "Canada",
"zip": "123 ABC",
"phone": "+15154346011",
"name": "test user",
"province_code": "ON",
"country_code": "CA",
"country_name": "Canada",
"default": true
}
],
"accepts_marketing_updated_at": "2020-06-14T15:59:02+05:30",
"marketing_opt_in_level": null,
"tax_exemptions": [],
"admin_graphql_api_id": "gid://shopify/Customer/3028204847146",
"default_address": {
"id": 3226192674858,
"customer_id": 3028204847146,
"first_name": "test",
"last_name": "user",
"company": null,
"address1": "123 Oak St",
"address2": null,
"city": "Ottawa",
"province": "Ontario",
"country": "Canada",
"zip": "123 ABC",
"phone": "+15154346011",
"name": "test user",
"province_code": "ON",
"country_code": "CA",
"country_name": "Canada",
"default": true
}
}
}

Related

When using the Quickbooks API explorer, read a vendor endpoint returns additional fields. How do I get these fields in actual API results?

Response from API via API explorer(by Intuit)
{
"Vendor": {
"BillAddr": {
"Id": "9",
"Line1": "31/2-34/2B, G01, Ground Floor (P V Enclave, V-Step Road)",
"Line2": "Kempapura",
"City": "Bangalore",
"Country": "India",
"CountrySubDivisionCode": "karnataka",
"PostalCode": "560037"
},
"BusinessNumber": "ABPFA3772K",
"Balance": 12960,
"BillRate": 0,
"Vendor1099": false,
"CurrencyRef": {
"value": "INR",
"name": "Indian Rupee"
},
"TDSEnabled": true,
"TDSEntityTypeId": 2,
"TDSSectionTypeId": 20,
"TDSOverrideThreshold": false,
"GSTIN": "29ABPFA3772K1ZT",
"GSTRegistrationType": "GST_REG_REG",
"CostRate": 0,
"domain": "QBO",
"sparse": false,
"Id": "5",
"SyncToken": "3",
"MetaData": {
"CreateTime": "2021-11-29T04:13:02-08:00",
"LastUpdatedTime": "2022-06-19T11:18:01-07:00"
},
"CompanyName": "Asyncauto",
"DisplayName": "Asyncauto",
"PrintOnCheckName": "Asyncauto",
"Active": true,
"V4IDPseudonym": "002085e0c7fca007484293913d58943f84b215",
"PrimaryPhone": {
"FreeFormNumber": "1231231234"
},
"PrimaryEmailAddr": {
"Address": "123123#mralbert.in"
}
},
"time": "2022-06-19T19:00:23.349-07:00"
}
Response from the actual API endpoint (quickbooks.api.intuit.com)
{
"Vendor": {
"BillAddr": {
"Id": "9",
"Line1": "31/2-34/2B, G01, Ground Floor (P V Enclave, V-Step Road)",
"Line2": "Kempapura",
"City": "Bangalore",
"Country": "India",
"CountrySubDivisionCode": "karnataka",
"PostalCode": "560037"
},
"BusinessNumber": "ABPFA3772K",
"Balance": 12960.00,
"Vendor1099": false,
"CurrencyRef": {
"value": "INR",
"name": "Indian Rupee"
},
"domain": "QBO",
"sparse": false,
"Id": "5",
"SyncToken": "3",
"MetaData": {
"CreateTime": "2021-11-29T04:13:02-08:00",
"LastUpdatedTime": "2022-06-19T11:18:01-07:00"
},
"CompanyName": "Asyncauto",
"DisplayName": "Asyncauto",
"PrintOnCheckName": "Asyncauto",
"Active": true,
"PrimaryPhone": {
"FreeFormNumber": "1231231234"
},
"PrimaryEmailAddr": {
"Address": "123123#mralbert.in"
}
},
"time": "2022-06-19T19:04:59.703-07:00"
}
Notice that in the second case these fields - "TDSEnabled","TDSEntityTypeId","TDSSectionTypeId","TDSOverrideThreshold","GSTIN","GSTRegistrationType", are missing.
How do I get these fields in the regular production endpoint?
Try using Postman and see if issue persist then you need to talk with quickbooks support.
I have found that in indian edition of quickbooks still has many issue open.

What does count at the end of response mean in Postman?

I am starting out with Postman. I made a simple GET request and got a response. At the end of the response, is "count=14". I am trying to understand what count means here?
I thought the number of records in the response is 14, but its only 10. So what does count=14 mean? Thankyou for your response!
This is the response I got:
{
"records": [
{
"id": "074df210-e1fb-4298-9407-d97881dc1af2",
"fullName": "Abcd",
"email": "janedoe#gmail.com",
"phone": "112-112-112"
},
{
"id": "4f0835d7-7c02-43da-86c7-77a03b4",
"fullName": "John Doe",
"email": "johndoe#gmail.com",
"phone": "1234-234"
},
{
"id": "a9e8cfb6-f62a-4a8e-84a5-df30",
"fullName": "Kitty Doe",
"email": "kittydoe#gmail.com",
"phone": "123-493-892"
},
{
"id": "319bdb34-e1c1-4e86-192",
"fullName": "Lovely Doe",
"email": "lovelydoe#gmail.com",
"phone": "089-829-3898"
},
{
"id": "1dfe5bba-e14b-4e9d-b90c",
"fullName": "Memory Doe",
"email": "memorydoe#gmail.com",
"phone": "273-872-8398"
},
{
"id": "61f466d5-ec00-76ccb88fff5e",
"fullName": "asdas",
"email": "asdas#gmail.com",
"phone": "123-123-9231"
},
{
"id": "f77b8e1d-70f2-4d44-b243-e61eac2a41a0",
"fullName": "asdasda",
"email": "asdasda#gmail.com",
"phone": "123-123-1291"
},
{
"id": "7d071c9e-fce6-4732-bed3-c18412a962c1",
"fullName": "Monday",
"email": "monday#gmail.com",
"phone": "123-129-1231"
},
{
"id": "5a1d1e9d-7396-41e3-aa96-864b",
"fullName": "Tuesday",
"email": "tuesday#gmail.com",
"phone": "123-241-2534"
},
{
"id": "f5da56d1-9fc2861e6da3",
"fullName": "Wednesday",
"email": "wednesday#gmail.com",
"phone": "129-121-1212"
}
],
"count": 14
}

Scenario Outline in Karate for multi-line JSON

How to use scenario outline to iterate for a JSON which is more than single cell
https://github.com/intuit/karate#the-cucumber-way
Data.json
[{
"address": {
"addressLine1": "ttes",
"addressLine2": "Test",
"addressLine3": "Test",
"addressType": "business",
"city": "TEST",
"company": "TEST",
"country": "TEST",
"state": "TEST",
"postalCode": "XXXX"
},
"name": {
"firstName": "TEST",
"lastName": "TEST",
"middleInit": "T",
"title": "Mr."
},
"phone": {
"phoneExtension": "1234",
"phoneNumber": "999999999",
"phoneType": "mobile"
},
"email": {
"emailAddress": "TEST#TEST.com"
}
},
{
"address": {
"addressLine1": "ttes1",
"addressLine2": "Test1",
"addressLine3": "Test1",
"addressType": "business",
"city": "TEST1",
"company": "TEST1",
"country": "TEST1",
"state": "TEST1",
"postalCode": "XXXX"
},
"name": {
"firstName": "TEST1",
"lastName": "TEST1",
"middleInit": "T",
"title": "Mr."
},
"phone": {
"phoneExtension": "1234",
"phoneNumber": "999999999",
"phoneType": "mobile"
},
"email": {
"emailAddress": "TEST#TEST1.com"
}
}]
====
Feature: Read from File
Background:
* def Testdata = read('Data.json')
Scenario Outline: [1] Test with multiple records on JSON
Given url_stg
And path 'test','test'
And request Testdata
When method POST
Examples:
|Testdata |
Please refer it in this documentation as it very straight forward for your case.
dynamic-scenario-outline
refer to this answer for different ways of providing data to Scenario Outline:
https://stackoverflow.com/a/56135752/8615449

How to make a payment with square from Dart code in flutter?

I need make payments with square, I used square_in_app_payments plugin but it only give me a nonce string that seems I have to send it to checkout api with items information inside JSON in http request, but I don't understand how to make it.
I only tried from postman make some samples fo square.
POST /v2/locations/{{location_id}}/checkouts HTTP/1.1
Host: connect.squareup.com
Authorization: Bearer {{access_token}}
Content-Type: application/json
cache-control: no-cache
Postman-Token: 5d2c05ae-11d6-42bd-bd1e-47fa44621a98
{
"idempotency_key": "60f919ba-2042-4402-bc66-e6455ec32349",
"order": {
"reference_id": "reference_id",
"line_items": [
{
"name": "Printed T Shirt",
"quantity": "2",
"base_price_money": {
"amount": 1500,
"currency": "USD"
},
"discounts": [
{
"name": "7% off previous season item",
"percentage": "7"
},
{
"name": "$3 off Customer Discount",
"amount_money": {
"amount": 300,
"currency": "USD"
}
}
]
},
{
"name": "Slim Jeans",
"quantity": "1",
"base_price_money": {
"amount": 2500,
"currency": "USD"
}
},
{
"name": "Woven Sweater",
"quantity": "3",
"base_price_money": {
"amount": 3500,
"currency": "USD"
},
"discounts": [
{
"name": "$11 off Customer Discount",
"amount_money": {
"amount": 1100,
"currency": "USD"
}
}
],
"taxes": [
{
"name": "Fair Trade Tax",
"percentage": "5"
}
]
}
],
"discounts": [
{
"name": "Father's day 12% OFF",
"percentage": "12"
},
{
"name": "Global Sales $55 OFF",
"amount_money": {
"amount": 5500,
"currency": "USD"
}
}
],
"taxes": [
{
"name": "Sales Tax",
"percentage": "8.5"
}
]
},
"ask_for_shipping_address": true,
"merchant_support_email": "merchant+support#website.com",
"pre_populate_buyer_email": "example#email.com",
"pre_populate_shipping_address": {
"address_line_1": "1455 Market St.",
"address_line_2": "Suite 600",
"locality": "San Francisco",
"administrative_district_level_1": "CA",
"postal_code": "94103",
"country": "US",
"first_name": "Jane",
"last_name": "Doe"
}
}
I need to know how to take the nonce string from card form of square_in_app_payments plugin and send it in http request for complete the payment.

Using Groovy in soapUI to extract a JSON field

I am using soapui with groovy for automation api test and I post a request REST, here is my response:
{`enter code here`
"firstname": "aaa",
"lastname": "bbb",
"address": "test",
"city": "city",
"country": "country",
"default": "false",
"id": "326"
}, {
"firstname": "ddd",
"lastname": "eee",
"address": "test",
"city": "city",
"country": "country",
"default": "True",
"id": "67"
}, {
"firstname": "hhh",
"lastname": "yyy",
"address": "test",
"city": "city",
"country": "country",
"default": "false",
"id": "345"
}, {
"firstname": "ooo",
"lastname": "hh",
"address": "test",
"city": "city",
"country": "country",
"default": "false",
"id": "3211"
},
I want to recover the id of the user who has a default "true"
Firstly, the response you posted is not valid json.
Should be something like this:
[
{
"firstname": "aaa",
"lastname": "bbb",
"address": "test",
"city": "city",
"country": "country",
"default": "false",
"id": "326"
},
{
"firstname": "ddd",
"lastname": "eee",
"address": "test",
"city": "city",
"country": "country",
"default": "True",
"id": "67"
},
{
"firstname": "hhh",
"lastname": "yyy",
"address": "test",
"city": "city",
"country": "country",
"default": "false",
"id": "345"
},
{
"firstname": "ooo",
"lastname": "hh",
"address": "test",
"city": "city",
"country": "country",
"default": "false",
"id": "3211"
}
]
If you're just interested in the groovy script, here it is:
package json
import com.eviware.soapui.support.XmlHolder
import groovy.json.*
//define the location of the JSON response
def response = context.expand('${post_json_data#Response}').toString()
//parse response as json
def json_response = new JsonSlurper().parseText(response)
//iterate on the list with if condition
json_response.eachWithIndex {
item, index ->
if(item.default == 'True') {
log.info "index: ${index}"
log.info "Item default value: ${item.default}"
log.info "Item id value : ${item.id}"
}
}