Customer get address via REST API

I accomplished to create a customer with an address but I don’t know how to get the billing address for a customer via the REST API. Anybody an idea?

So far I tried:

r = requests.get(eUrl + '/api/resource/Address', headers={ "Authorization": "token " + eKey }, params={
    'limit_page_length': 1,
    'filters': '[["Address", "links","=","' + customerId + '"]]'
})

the address doctype has a field called address type. you can filter it to get only the “Billing” addresses

2 Likes

Thank you, thats a good idea. Do you know now how to also filter by customer?

[“Dynamic Link”, “links”, “link_name”, “=”, “CUSTOMER”] should do the trick

Thanks for the idea! Sadly I get:

{
"exc_type": "DataError",
"exception": "frappe.exceptions.DataError: Field not permitted in query: links",
"exc": "[\"Traceback (most recent call last):\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/app.py\\\", line 68, in application\\n    response = frappe.api.handle()\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/api.py\\\", line 129, in handle\\n    data = frappe.call(frappe.client.get_list, doctype, **frappe.local.form_dict)\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py\\\", line 1208, in call\\n    return fn(*args, **newargs)\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/client.py\\\", line 47, in get_list\\n    validate_args(args)\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/desk/reportview.py\\\", line 62, in validate_args\\n    validate_filters(data, data.filters)\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/desk/reportview.py\\\", line 114, in validate_filters\\n    raise_invalid_field(fieldname)\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/desk/reportview.py\\\", line 142, in raise_invalid_field\\n    frappe.throw(_('Field not permitted in query') + ': {0}'.format(fieldname), frappe.DataError)\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py\\\", line 439, in throw\\n    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py\\\", line 418, in msgprint\\n    _raise_exception()\\n  File \\\"/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py\\\", line 372, in _raise_exception\\n    raise raise_exception(msg)\\nfrappe.exceptions.DataError: Field not permitted in query: links\\n\"]",
"_server_messages": "[\"{\\\"message\\\": \\\"Field not permitted in query: links\\\", \\\"indicator\\\": \\\"red\\\", \\\"raise_exception\\\": 1}\"]"

}

I made a mistake, it should be like this: api/resource/Address?filters=[[“Dynamic%20Link”,“link_name”,“=”,“CUSTOMER_NAME”]]

without the “links” key

2 Likes

Ahh thank you very much!