How to update a new json in old json in postgres? - postgresql

this is my data which is available in the database.
INSERT INTO suppliers (id, "createdAt", "updatedAt", "userId", "fullName", email, phone, "profilePicture", "isEnabled", "role", "originDistrict", tln, "companyName", "companyAddress", "assignKam", "assignCluster", "vehicleProvide", "makePayout", "subsType", gender, status, "lookAtBid", "bidAccepted", "activeTrip", "isVerified") VALUES(36, '2022-02-21 18:46:01.527', '2022-09-12 13:20:31.132', '01FRJH5K6GV6KT4YP7RQ4H7N7K', 'syed musa tazim', NULL, '+8801696678835', NULL, false, 'vendor', '{"id": 46, "nameBn": "গাজীপুর", "nameEn": "Gazipur", "status": "active", "createdAt": "2021-12-31T18:08:40.056Z"}'::jsonb, NULL, 'Rofiqul Islam (GZP)', NULL, '{"role": "kam", "team": "vendor_team", "zone": "gazipur", "email": "tauhi15#loopfreight.io", "phone": "+8801721666512", "userId": "01GCDMQ7DS48XTCMT5JBYSS4NF", "fullName": "Mohammad Tareq"}'::jsonb, '{"role": "cluster_head", "zone": "gazipur", "email": "a28#gmail.com", "phone": "+8801328282828", "userId": "01GCNEE49Z3ZCBT73BK2BHVY6P", "fullName": "Iftikar Bhaia Gazipur"}'::jsonb, 20, 'monday'::public."suppliers_makepayout_enum", 'gold'::public."suppliers_substype_enum", 'male'::public."suppliers_gender_enum", 'inactive'::public."suppliers_status_enum", 0, 0, 0, false); INSERT INTO suppliers (id, "createdAt", "updatedAt", "userId", "fullName", email, phone, "profilePicture", "isEnabled", "role", "originDistrict", tln, "companyName", "companyAddress", "assignKam", "assignCluster", "vehicleProvide", "makePayout", "subsType", gender, status, "lookAtBid", "bidAccepted", "activeTrip", "isVerified") VALUES(143, '2022-07-14 10:39:36.397', '2023-01-11 16:03:26.445', '01G7XG2M1X1Y60H3W6GYBR2Q40', 'abcd', 'kamrul.islam#loopfreight.ios', '+8801828378263', NULL, true, 'vendor', '{"id": 46, "nameBn": "গাজীপুর", "nameEn": "Gazipur", "status": "active", "createdAt": "2021-12-31T18:08:40.056Z"}'::jsonb, NULL, 'Transport Agency (GZP)', 'abcd', '{"role": "kam", "team": "vendor_team", "zone": "gazipur", "email": "FoxVTNJ#test.com", "phone": "+8801312121215", "userId": "01GCB9NMCR0FVE7NTE825T06PF", "fullName": "A.B.M. Asaff-Ud-Daula"}'::jsonb, '{"role": "cluster_head", "zone": "gazipur", "email": "a28#gmail.com", "phone": "+8801328282828", "userId": "01GCNEE49Z3ZCBT73BK2BHVY6P", "fullName": "Iftikar Bhaia Gazipur"}'::jsonb, 50, 'wednesday'::public."suppliers_makepayout_enum", 'bronze'::public."suppliers_substype_enum", 'male'::public."suppliers_gender_enum", 'active'::public."suppliers_status_enum", 3, 0, 0, true); INSERT INTO suppliers (id, "createdAt", "updatedAt", "userId", "fullName", email, phone, "profilePicture", "isEnabled", "role", "originDistrict", tln, "companyName", "companyAddress", "assignKam", "assignCluster", "vehicleProvide", "makePayout", "subsType", gender, status, "lookAtBid", "bidAccepted", "activeTrip", "isVerified") VALUES(51, '2022-02-21 18:46:01.527', '2022-10-19 14:17:16.790', '01FV9WW0SZ58C3HX1XV8N6AKSR', 'some vendor 3 update yes', NULL, '+8801711223343', NULL, false, 'vendor', '{"id": 46, "nameBn": "গাজীপুর", "nameEn": "Gazipur", "status": "active", "createdAt": "2021-12-31T18:08:40.056Z"}'::jsonb, NULL, 'Matrichaya Transport Agency (GZP) yes', 'some vendor 3 company address', '{"role": "kam", "team": "vendor_team", "zone": "gazipur", "email": "tauhi15#loopfreight.io", "phone": "+8801721666512", "userId": "01GCDMQ7DS48XTCMT5JBYSS4NF", "fullName": "Mohammad Tareq"}'::jsonb, '{"role": "cluster_head", "zone": "gazipur", "email": "a28#gmail.com", "phone": "+8801328282828", "userId": "01GCNEE49Z3ZCBT73BK2BHVY6P", "fullName": "Bimol Das"}'::jsonb, 200, 'monday'::public."suppliers_makepayout_enum", 'gold'::public."suppliers_substype_enum", 'male'::public."suppliers_gender_enum", 'inactive'::public."suppliers_status_enum", 0, 0, 0, true); INSERT INTO suppliers (id, "createdAt", "updatedAt", "userId", "fullName", email, phone, "profilePicture", "isEnabled", "role", "originDistrict", tln, "companyName", "companyAddress", "assignKam", "assignCluster", "vehicleProvide", "makePayout", "subsType", gender, status, "lookAtBid", "bidAccepted", "activeTrip", "isVerified") VALUES(45, '2022-02-21 18:46:01.527', '2022-10-18 10:13:43.622', '01FSP5XNHEN9WH06Z320YSE416', 'tazim', NULL, '+8801676553344', NULL, false, 'vendor', '{"id": 46, "nameBn": "গাজীপুর", "nameEn": "Gazipur", "status": "active", "createdAt": "2021-12-31T18:08:40.056Z"}'::jsonb, NULL, 'Md. Parvez Alam (GZP)', 'h-747, road-08 ,Adabor ,Dhaka', '{"role": "kam", "team": "vendor_team", "zone": "gazipur", "email": "tauhi15#loopfreight.io", "phone": "+8801721666512", "userId": "01GCDMQ7DS48XTCMT5JBYSS4NF", "fullName": "Mohammad Tareq"}'::jsonb, '{"role": "cluster_head", "zone": "gazipur", "email": "a28#gmail.com", "phone": "+8801328282828", "userId": "01GCNEE49Z3ZCBT73BK2BHVY6P", "fullName": "Iftikar Bhaia Gazipur"}'::jsonb, 12, 'monday'::public."suppliers_makepayout_enum", 'tin'::public."suppliers_substype_enum", 'male'::public."suppliers_gender_enum", 'inactive'::public."suppliers_status_enum", 0, 0, 0, false); INSERT INTO suppliers (id, "createdAt", "updatedAt", "userId", "fullName", email, phone, "profilePicture", "isEnabled", "role", "originDistrict", tln, "companyName", "companyAddress", "assignKam", "assignCluster", "vehicleProvide", "makePayout", "subsType", gender, status, "lookAtBid", "bidAccepted", "activeTrip", "isVerified") VALUES(138, '2022-07-06 13:33:43.305', '2023-01-11 16:33:44.418', '01G796VP5GZWBM90BSXSB5QE6A', 'testing vendor fullname 5', NULL, '+8801345454545', NULL, true, 'vendor', '{"id": 46, "nameBn": "গাজীপুর", "nameEn": "Gazipur", "status": "active", "createdAt": "2021-12-31T18:08:40.056Z"}'::jsonb, NULL, 'Connect Transport Agency (GZP)', 'tesiting vendor address', '{"role": "kam", "team": "vendor_team", "zone": "gazipur", "email": "FoxVTNJ#test.com", "phone": "+8801312121215", "userId": "01GCB9NMCR0FVE7NTE825T06PF", "fullName": "A.B.M. Asaff-Ud-Daula"}'::jsonb, '{"role": "cluster_head", "zone": "gazipur", "email": "a28#gmail.com", "phone": "+8801328282828", "userId": "01GCNEE49Z3ZCBT73BK2BHVY6P", "fullName": "Iftikar Bhaia Gazipur"}'::jsonb, 0, 'wednesday'::public."suppliers_makepayout_enum", 'gold'::public."suppliers_substype_enum", 'male'::public."suppliers_gender_enum", 'active'::public."suppliers_status_enum", 14, 0, 1, true);
I want to replace this
{"role": "cluster_head", "zone": "gazipur", "email": "a28#gmail.com", "phone": "+8801328282828", "userId": "01GCNEE49Z3ZCBT73BK2BHVY6P", "fullName": "Iftikar Bhaia Gazipur"}
with
{userId: '01GBSDPSCAE74FVCK2XPPCRDYH',profilePicture: 'https://dev-cdn.loopfreight.io/public/cd4a89cae5d4516efabf73ccd774583e.jpg',fullName: 'Rayhan Zaman',isEnabled: true,isVerified: true,designation: 'Manager ',department: 'operation',zone: 'khulna',phone: '+8801811111111',email: 'rayhan#gmail.com',createdAt: '2022-08-31T07:44:00.905Z',gender: 'male',role: 'cluster_head'}
how can I change it?
I will get the 2nd json from another service. So I want to replace it.
I have tried like this
update suppliers set "assignCluster" = jsonb_set({userId: '01GBSDPSCAE74FVCK2XPPCRDYH',profilePicture: 'https://dev-cdn.loopfreight.io/public/cd4a89cae5d4516efabf73ccd774583e.jpg',fullName: 'Rayhan Zaman',isEnabled: true,isVerified: true,designation: 'Manager ',department: 'operation',zone: 'khulna',phone: '+8801811111111',email: 'rayhan#gmail.com',createdAt: '2022-08-31T07:44:00.905Z',gender: 'male',role: 'cluster_head'})::jsonb where "assignCluster"->>"userId" = '01GBSDPSCAE74FVCK2XPPCRDYH';

Don't use jsonb_set. You want to replace the entire value of the column, not manipulate some JSON.
Also you need to put the JSON value in an SQL literal, and properly quote property names and strings in it.
update suppliers
set "assignCluster" = '{"userId": "01GBSDPSCAE74FVCK2XPPCRDYH", "profilePicture": "https://dev-cdn.loopfreight.io/public/cd4a89cae5d4516efabf73ccd774583e.jpg", "fullName": "Rayhan Zaman", "isEnabled": true, "isVerified": true, "designation": "Manager", "department": "operation", "zone": "khulna", "phone": "+8801811111111", "email": "rayhan#gmail.com", "createdAt": "2022-08-31T07:44:00.905Z", "gender": "male", "role": "cluster_head"}'
where "assignCluster"->>'userId' = '01GBSDPSCAE74FVCK2XPPCRDYH';

Related

How can I sort an object by key value?

I have this data and I want to sort all the type_description value ascending. How can I do this?
data = [
{
'name': 'asd',
'contact': [{
"country_code": "1",
"area_code": null,
"contact_no": "4616984351",
"email": null,
"type_description": "Mobile - Primary"
},
{
"country_code": null,
"area_code": "416",
"contact_no": "6984351",
"email": null,
"type_description": "Landline - Business"
},
{
"country_code": null,
"area_code": null,
"contact_no": null,
"email": "n81ikrfepi#temporary-mail.net",
"type_description": "Email - Primary"
}
]
},
{
'name': 'dsa',
'contact': [{
"country_code": "1",
"area_code": null,
"contact_no": "4616984351",
"email": null,
"type_description": "Mobile - Primary"
},
{
"country_code": null,
"area_code": "416",
"contact_no": "6984351",
"email": null,
"type_description": "Landline - Business"
},
{
"country_code": null,
"area_code": null,
"contact_no": null,
"email": "n81ikrfepi#temporary-mail.net",
"type_description": "Email - Primary"
}
]
}
];
I'm expecting the data to be look like this
data = [
{
'name': 'asd',
'contact': [{
"country_code": null,
"area_code": null,
"contact_no": null,
"email": "n81ikrfepi#temporary-mail.net",
"type_description": "Email - Primary"
},
{
"country_code": null,
"area_code": "416",
"contact_no": "6984351",
"email": null,
"type_description": "Landline - Business"
},
{
"country_code": "1",
"area_code": null,
"contact_no": "4616984351",
"email": null,
"type_description": "Mobile - Primary"
},
]
},
{
'name': 'dsa',
'contact': [{
"country_code": null,
"area_code": null,
"contact_no": null,
"email": "n81ikrfepi#temporary-mail.net",
"type_description": "Email - Primary"
},
{
"country_code": null,
"area_code": "416",
"contact_no": "6984351",
"email": null,
"type_description": "Landline - Business"
},
{
"country_code": "1",
"area_code": null,
"contact_no": "4616984351",
"email": null,
"type_description": "Mobile - Primary"
},
]
}
];
do insert the jsondata in the variable name datastore
List<Map<String,dynamic>> dataStrore = [put all json data here];
Now do the sort
dataStore.forEach((user){
List<Map<String, dynamic>> contact = user['contact'];
contact.sort((a,b)) => a['type_discription'].compareTo(b['typediscription'])));
})
Now print and see the sorted data
print(dataStore)

Multiple concurrent rides for Guests not working

When attempting multiple ride request, "request_id" of first ride is returned in the second request which means new ride is not booked for the second ride request. Please see the request/response below,
Ride Request 1 :
https://sandbox-api.uber.com/v1.2/requests
{
"start_latitude": "37.713706",
"start_longitude": "-122.403708",
"end_latitude": "37.744186",
"end_longitude": "-122.466388",
"fare_id" :"48ba6200227450d3965081024657275f9d1ff5cbb719aaa0bf30be234325f300",
"guest_id" : "5b357e78-c495-4614-afa1-e2a0b0f3dffc",
"product_id": "a1111c8c-c720-46c3-8534-2fcdd730040d",
}
**Response :**
{
"status": "processing",
"product_id": "a1111c8c-c720-46c3-8534-2fcdd730040d",
"destination": {
"latitude": 37.744186,
"longitude": -122.466388
},
"driver": null,
"pickup": {
"latitude": 37.713706,
"longitude": -122.403708
},
"request_id": "2be01f1e-6687-4393-9fcf-e3b840803849",
"eta": null,
"location": null,
"vehicle": null,
"shared": false,
"guest": {
"guest_id": "5b357e78-c495-4614-afa1-e2a0b0f3dffc",
"phone_number": "+14150001234",
"first_name": "Jane",
"last_name": "Smith",
"email": "jane.smith#email.com"
}
}
Ride Request 2 :
https://sandbox-api.uber.com/v1.2/requests
{
"start_latitude": "37.743033",
"start_longitude": "-122.389675",
"end_latitude": "37.7759073",
"end_longitude": "-122.4245247",
"fare_id" :"502eed0ccbb906363df23cf9e81ecb6ceb35b8af46a25194775ac9560871da12",
"guest_id" : "ecc5adeb-fa20-4580-ac24-1ae184bffce9",
"product_id" : "26546650-e557-4a7b-86e7-6a3942445247"
}
Response:
{
"status": "processing",
"product_id": "26546650-e557-4a7b-86e7-6a3942445247",
"destination": {
"latitude": 37.744186,
"longitude": -122.466388
},
"driver": null,
"pickup": {
"latitude": 37.713706,
"longitude": -122.403708
},
"request_id": "2be01f1e-6687-4393-9fcf-e3b840803849",
"eta": null,
"location": null,
"vehicle": null,
"shared": false,
"guest": {
"guest_id": "ecc5adeb-fa20-4580-ac24-1ae184bffce9",
"phone_number": "+14150001234",
"first_name": "Jane",
"last_name": "Smith",
"email": "jane.smith#email.com"
}
}
You can only have one concurrent ride per user/token so it is expected. In your case you just made a ride request in the sandbox and did not progress the state to completed or cancel the ride.

uber RUSH API sandbox deliveries is_fragile value incorrect, bug?

While experimenting with the uber deliveries API sandbox I noticed that when I POST to https://sandbox-api.uber.com/v1/deliveries to create delivery of a new item with item[]."is fragile": true, that the response from the sandbox incorrectly shows item[]."is fragile": false. At least I think this is incorrect, I didn't see it listed as a known limitation of the sandbox. Is this a bug?
More information:
OS: Ubuntu 16.04.1 LTS
Client: Postman 4.9.0
POST request to URL https://sandbox-api.uber.com/v1/deliveries
POST /v1/deliveries HTTP/1.1
Host: sandbox-api.uber.com
Authorization: [redacted]
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: [redacted]
{
"items": [
{
"title": "Fragile Item",
"quantity": 1,
"price": 30,
"is_fragile": true,
"currency_code": "USD",
}
],
"dropoff": {
"location": {
"address": "530 W 113th Street",
"address_2": "Floor 2",
"city": "New York",
"country": "US",
"postal_code": "10025",
"state": "NY"
},
"contact": {
"first_name": "Alice",
"last_name": "Dropoff",
"email": "tomb#cryptocracy.net",
"phone": {
"number": "+19177447934",
"sms_enabled": "true",
},
}
},
"pickup": {
"location": {
"address": "636 W 28th Street",
"address_2": "Floor 2",
"city": "New York",
"country": "US",
"postal_code": "10001",
"state": "NY"
},
"contact": {
"first_name": "Bob",
"last_name": "Pickup",
"email": "tomb#cryptocracy.net",
"phone": {
"number": "+19177447934",
"sms_enabled": "true",
},
},
},
}
Response from the sandbox:
{
"status": "processing",
"dropoff": {
"eta": 12,
"signature_required": false,
"contact": {
"first_name": "Alice",
"last_name": "Dropoff",
"send_sms_notifications": true,
"send_email_notifications": true,
"phone": {
"sms_enabled": true,
"number": "+19177447934"
},
"email": "tomb#cryptocracy.net"
},
"special_instructions": "",
"location": {
"city": "New York",
"country": "US",
"longitude": -73.963863,
"state": "NY",
"postal_code": "10025",
"address_2": "Floor 2",
"address": "530 W 113th Street",
"latitude": 40.805264
},
"signature_image": {
"url": "",
"expires_at": "-62135596800"
},
"courier_notes": {}
},
"fee": 5,
"quote_id": "c7e135da-957e-40b7-a2c5-5d468dc1d686",
"courier": null,
"items": [
{
"weight": 0,
"title": "Bottle 3",
"price": 30,
"is_fragile": false,
"height": 0,
"width": 0,
"length": 0,
"currency_code": "USD",
"quantity": 1
}
],
"created_at": 1480961485,
"delivery_id": "21b1b8de-2cea-4bc4-a316-2fd7598787c7",
"pickup": {
"eta": 7,
"signature_required": false,
"contact": {
"first_name": "Bob",
"last_name": "Pickup",
"send_sms_notifications": true,
"send_email_notifications": true,
"phone": {
"sms_enabled": true,
"number": "+19177447934"
},
"email": "tomb#cryptocracy.net"
},
"special_instructions": "",
"location": {
"city": "New York",
"country": "US",
"longitude": -74.0064109,
"state": "NY",
"postal_code": "10001",
"address_2": "Floor 2",
"address": "636 W 28th Street",
"latitude": 40.7527293
},
"signature_image": {
"url": "",
"expires_at": "-62135596800"
},
"courier_notes": {}
},
"order_reference_id": "",
"tracking_url": "https://api.uber.com/v1/sandbox/map",
"currency_code": "USD"
}
This seems to be a bug in the Uber sandbox environment for the Deliveries API.

Tax lines won't automatically generate in Shopify API order

I am posting the following to the Shopify API order endpoint:
{
"order": {
"email": "some#email.com",
"financial_status": "paid",
"fulfillment_status": null,
"send_receipt": true,
"send_fulfillment_receipt": true,
"note": "Created by somename",
"line_items": [
{
"variant_id": 21718275463,
"quantity": 1,
"price": 99,
"requires_shipping": true,
"product_id": 6820646151
},
{
"variant_id": 21717700871,
"quantity": 1,
"price": 1000,
"requires_shipping": true,
"product_id": 6820646151
},
{
"variant_id": 21717690055,
"quantity": 1,
"price": 555,
"requires_shipping": true,
"product_id": 6821668807
}
],
"processing_method": "offsite",
"shipping_address": {
"first_name": "Chris",
"address1": "10101 Musick Road",
"phone": "9999999999",
"city": "St. Louis",
"zip": "63123",
"province": "MO",
"country": "United States",
"last_name": "Becker",
"name": "Chris Becker",
"country_code": "US",
"province_code": "MO"
},
"source_name": "somename",
"taxes_included": false,
"shipping_lines": [
{
"title": "standard",
"price": 0.00,
"code": null,
"source": "brand owner on shopify",
"carrier_identifier": null,
"tax_lines": null
}
],
"tags": "some Order"
}
}
and receiving a response without tax lines that are filled. I have seen on the shopify forum that the taxlines are supposed to then be automatically
calculated and filled by shopify. I tried doing it with a customer as well but that didn't work either.
The Orders API will not auto-calculate the taxes but if your app knows how much they are then you can include this data using tax_lines and total_tax:
{
"order": {
"line_items": [{
"title": "Big Brown Bear Boots",
"price": 74.99,
"quantity": 3,
"tax_lines": [{
"price": 13.50,
"rate": 0.06,
"title": "State tax"
}]
}],
"total_tax": 13.50
}
}

Why can't I remove the Shipping address from this IPP QBO v3 API Customer object

I'm using the Intuit Partner Platform v3 QBO API to try to update a Customer object. The sole objective for the purpose of this post is to remove the shipping address.
Here's the original object, queried before the change:
{
"domain": "QBO",
"FamilyName": "last",
"DisplayName": "my display name",
"Title": "mr.",
"PreferredDeliveryMethod": "Print",
"GivenName": "first",
"FullyQualifiedName": "my display name",
"BillWithParent": false,
"Job": false,
"BalanceWithJobs": 0,
"Taxable": true,
"MetaData": {
"CreateTime": "2014-09-22T18:49:43-07:00",
"LastUpdatedTime": "2014-09-22T18:49:44-07:00"
},
"BillAddr": {
"City": "city 1",
"Country": "USA",
"Line1": "billing address line 1\nbilling address line 2",
"PostalCode": "98765",
"CountrySubDivisionCode": "ST",
"Id": "130"
},
"MiddleName": "mid",
"Active": true,
"Balance": 0,
"SyncToken": "0",
"Suffix": "suf",
"CompanyName": "my company name",
"ShipAddr": {
"City": "city 2",
"Country": "USA",
"Line1": "shipping address line 1\nshipping address line 2",
"PostalCode": "54321",
"CountrySubDivisionCode": "TS",
"Id": "131"
},
"PrintOnCheckName": "my display name",
"sparse": false,
"Id": "212"
}
Here's the request body when I do the update (SyncToken matches, sparse is false...):
{
"domain": "QBO",
"DisplayName": "my display name",
"Title": "mr.",
"PreferredDeliveryMethod": "Print",
"GivenName": "first",
"FullyQualifiedName": "my display name",
"BillWithParent": false,
"Job": false,
"BalanceWithJobs": 0.0,
"Taxable": true,
"MetaData": {
"CreateTime": "2014-09-22T18:49:43-07:00",
"LastUpdatedTime": "2014-09-22T18:49:43-07:00"
},
"sparse": false,
"MiddleName": "mid",
"Active": true,
"Balance": 0.0,
"SyncToken": 0,
"Suffix": "suf",
"CompanyName": "my company name",
"FamilyName": "last",
"PrintOnCheckName": "my display name",
"BillAddr": {
"CountrySubDivisionCode": "ST",
"City": "city 1",
"PostalCode": "98765",
"Line1": "billing address line 1\nbilling address line 2",
"Country": "USA"
},
"Id": "212"
}
And then when I read it again afterwards, it still has the shipping address (though note the SyncToken has incremented, so the API 'got the message':
{
"domain": "QBO",
"FamilyName": "last",
"DisplayName": "my display name",
"Title": "mr.",
"PreferredDeliveryMethod": "Print",
"GivenName": "first",
"FullyQualifiedName": "my display name",
"BillWithParent": false,
"Job": false,
"BalanceWithJobs": 0,
"Taxable": true,
"MetaData": {
"CreateTime": "2014-09-22T18:49:43-07:00",
"LastUpdatedTime": "2014-09-22T18:51:20-07:00"
},
"BillAddr": {
"City": "city 1",
"Country": "USA",
"Line1": "billing address line 1\nbilling address line 2",
"PostalCode": "98765",
"CountrySubDivisionCode": "ST",
"Id": "130"
},
"MiddleName": "mid",
"Active": true,
"Balance": 0,
"SyncToken": "1",
"Suffix": "suf",
"CompanyName": "my company name",
"ShipAddr": {
"City": "city 1",
"Country": "USA",
"Line1": "billing address line 1\nbilling address line 2",
"PostalCode": "98765",
"CountrySubDivisionCode": "ST",
"Id": "130"
},
"PrintOnCheckName": "my display name",
"sparse": false,
"Id": "212"
}
I've found that if I just set a SINGLE line of the shipping address (to 'x', for example, then the change goes through, but what I'm trying above (which is what I really want—to DELETE the shipping address), has failed. I don't see it on the known issues list, but I know that when a friend of mine recently migrated from QuickBooks Desktop to QuickBooks Online, shipping addresses were populated where previously there was just a billing address.
Anyone know how to achieve this?
Thanks!
UPDATE Adding working JSON example.
{
"Customer": {
"Taxable": false,
"BillAddr": {
"Id": "9",
"Line1": "100 Street",
"City": "Bangalore",
"Country": "India",
"CountrySubDivisionCode": "Karnataka",
"PostalCode": "560103"
},
"ShipAddr": {
"Id": "9",
"Line1": "100 Street",
"City": "Bangalore",
"Country": "India",
"CountrySubDivisionCode": "Karnataka",
"PostalCode": "560103"
},
"Job": false,
"BillWithParent": false,
"Balance": 0,
"BalanceWithJobs": 0,
"PreferredDeliveryMethod": "Email",
"domain": "QBO",
"sparse": false,
"Id": "16",
"SyncToken": "0",
"MetaData": {
"CreateTime": "2014-09-22T21:54:13-07:00",
"LastUpdatedTime": "2014-09-22T21:54:13-07:00"
},
"GivenName": "AA",
"FullyQualifiedName": "AA",
"DisplayName": "AA",
"PrintOnCheckName": "AA",
"Active": true
},
"time": "2014-09-22T21:55:17.28-07:00"
}
Update Request
{
"Taxable": false,
"BillAddr": {
"Id": "9",
"Line1": "100 Street",
"City": "Bangalore",
"Country": "India",
"CountrySubDivisionCode": "Karnataka",
"PostalCode": "560103"
},
"Job": false,
"BillWithParent": false,
"Balance": 0,
"BalanceWithJobs": 0,
"PreferredDeliveryMethod": "Email",
"domain": "QBO",
"sparse": false,
"Id": "16",
"SyncToken": "0",
"MetaData": {
"CreateTime": "2014-09-22T21:54:13-07:00",
"LastUpdatedTime": "2014-09-22T21:54:13-07:00"
},
"GivenName": "AA",
"FullyQualifiedName": "AA",
"DisplayName": "AA",
"PrintOnCheckName": "AA",
"Active": true
}
Get By Id
{
"Customer": {
"Taxable": false,
"BillAddr": {
"Id": "9",
"Line1": "100 Street",
"City": "Bangalore",
"Country": "India",
"CountrySubDivisionCode": "Karnataka",
"PostalCode": "560103"
},
"Job": false,
"BillWithParent": false,
"Balance": 0,
"BalanceWithJobs": 0,
"PreferredDeliveryMethod": "Email",
"domain": "QBO",
"sparse": false,
"Id": "16",
"SyncToken": "1",
"MetaData": {
"CreateTime": "2014-09-22T21:54:13-07:00",
"LastUpdatedTime": "2014-09-22T21:56:21-07:00"
},
"GivenName": "AA",
"FullyQualifiedName": "AA",
"DisplayName": "AA",
"PrintOnCheckName": "AA",
"Active": true
},
"time": "2014-09-22T21:56:49.814-07:00"
}
Did you try XML payload. It worked fine for me. PFB below request/response.
I'll verify the JSON way and update this post.
<Customer xmlns="http://schema.intuit.com/finance/v3" domain="QBO" sparse="false">
<Id>14</Id>
<SyncToken>0</SyncToken>
<MetaData>
<CreateTime>2014-09-22T21:04:02-07:00</CreateTime>
<LastUpdatedTime>2014-09-22T21:04:02-07:00</LastUpdatedTime>
</MetaData>
<GivenName>Neo</GivenName>
<FamilyName>Light</FamilyName>
<FullyQualifiedName>Neo Light</FullyQualifiedName>
<CompanyName>ABC</CompanyName>
<DisplayName>Neo Light</DisplayName>
<PrintOnCheckName>Neo Light</PrintOnCheckName>
<Active>true</Active>
<PrimaryEmailAddr>
<Address>abc#abc.co.in</Address>
</PrimaryEmailAddr>
<Taxable>false</Taxable>
<BillAddr>
<Id>7</Id>
<Line1>ABC Street</Line1>
<City>Bangalore</City>
<Country>India</Country>
<CountrySubDivisionCode>Karnataka</CountrySubDivisionCode>
<PostalCode>560103</PostalCode>
</BillAddr>
<ShipAddr>
<Id>7</Id>
<Line1>ABC Street</Line1>
<City>Bangalore</City>
<Country>India</Country>
<CountrySubDivisionCode>Karnataka</CountrySubDivisionCode>
<PostalCode>560103</PostalCode>
</ShipAddr>
<Job>false</Job>
<BillWithParent>false</BillWithParent>
<Balance>0</Balance>
<BalanceWithJobs>0</BalanceWithJobs>
<PreferredDeliveryMethod>Email</PreferredDeliveryMethod>
</Customer>
Update request
<Customer xmlns="http://schema.intuit.com/finance/v3" domain="QBO" sparse="false">
<Id>14</Id>
<SyncToken>0</SyncToken>
<MetaData>
<CreateTime>2014-09-22T21:04:02-07:00</CreateTime>
<LastUpdatedTime>2014-09-22T21:04:02-07:00</LastUpdatedTime>
</MetaData>
<GivenName>Neo</GivenName>
<FamilyName>Light</FamilyName>
<FullyQualifiedName>Neo Light</FullyQualifiedName>
<CompanyName>ABC</CompanyName>
<DisplayName>Neo Light</DisplayName>
<PrintOnCheckName>Neo Light1</PrintOnCheckName>
<Active>true</Active>
<PrimaryEmailAddr>
<Address>abc#abc.co.in</Address>
</PrimaryEmailAddr>
<Taxable>false</Taxable>
<BillAddr>
<Id>7</Id>
<Line1>ABC Street</Line1>
<City>Bangalore</City>
<Country>India</Country>
<CountrySubDivisionCode>Karnataka</CountrySubDivisionCode>
<PostalCode>560103</PostalCode>
</BillAddr>
<Job>false</Job>
<BillWithParent>false</BillWithParent>
<Balance>0</Balance>
<BalanceWithJobs>0</BalanceWithJobs>
<PreferredDeliveryMethod>Email</PreferredDeliveryMethod>
</Customer>
Verified that 'shipAddr' is not present anymore
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-09-22T21:07:31.919-07:00">
<Customer domain="QBO" sparse="false">
<Id>14</Id>
<SyncToken>1</SyncToken>
<MetaData>
<CreateTime>2014-09-22T21:04:02-07:00</CreateTime>
<LastUpdatedTime>2014-09-22T21:06:58-07:00</LastUpdatedTime>
</MetaData>
<GivenName>Neo</GivenName>
<FamilyName>Light</FamilyName>
<FullyQualifiedName>Neo Light</FullyQualifiedName>
<CompanyName>ABC</CompanyName>
<DisplayName>Neo Light</DisplayName>
<PrintOnCheckName>Neo Light1</PrintOnCheckName>
<Active>true</Active>
<PrimaryEmailAddr>
<Address>abc#abc.co.in</Address>
</PrimaryEmailAddr>
<Taxable>false</Taxable>
<BillAddr>
<Id>7</Id>
<Line1>ABC Street</Line1>
<City>Bangalore</City>
<Country>India</Country>
<CountrySubDivisionCode>Karnataka</CountrySubDivisionCode>
<PostalCode>560103</PostalCode>
</BillAddr>
<Job>false</Job>
<BillWithParent>false</BillWithParent>
<Balance>0</Balance>
<BalanceWithJobs>0</BalanceWithJobs>
<PreferredDeliveryMethod>Email</PreferredDeliveryMethod>
</Customer>
</IntuitResponse>
Thanks