4D Rest API Integration

Hey everybody,

First time here. Does anybody have any experience integrating 4D with WooCommerce or TaxJar. If not does anybody have any experience integrating 4D with an online shopping cart via REST api. I have minimal experience with 4D so any help would be appreciated! Thank you!

Hello,

I think it would be better if you could be more specific on which part of the process you are looking for help.

is it the authentication, URL encoding, JSON, XML, HTTP post/get…?

Thanks for the response…

I guess the larger problem… is that I don’t know what i’m doing. And i’m struggling to find the API documentation for 4d to begin with.

Hello,
This website is made in 4D … https://www.livrerdubonheur.com
Warning it should change its name in the days that arrive: https://www.aliceetvalentin.com

If you have questions I can give you some tracks …

REST, at the most basic level, requires only few commands in 4D

http://doc.4d.com/4Dv15/4D/15.4/HTTP-Request.301-3274755.en.htmlHTTP Request> and related features

http://doc.4d.com/4Dv15/4D/15.4/JSON-Parse.301-3274447.en.htmlJSON Parse> and related features

or, if I may turn the question: is their another language (C, JS, PHP, etc) you would feel more comfortable with?

the question might be better asked like

how would you do this (insert code here) in 4D?

: Gregory Foreman

Hello,
This website is made in 4D … https://www.livrerdubonheur.com
Warning it should change its name in the days that arrive:
https://www.aliceetvalentin.com

If you have questions I can give you some tracks …

When you say it is made in 4D, what does that mean exactly? Isn’t that bootstrap? Is your cart system integrated with 4d?

: Keisuke MIYAKO

REST, at the most basic level, requires only few commands in 4D

HTTP Request and related features

JSON Parse and related features

or, if I may turn the question: is their another language (C, JS,
PHP, etc) you would feel more comfortable with?

the question might be better asked like

how would you do this (insert code here) in 4D?

This is a good question. I guess I should explain myself better. There are two things I am trying to do:

  1. Our website orders should integrate directly into 4D. So I presume I would have to have 4D HTTP GET the necessary fields from our website correct? Or we could export the orders some how from online, maybe xml, and import them into 4d?

  2. Integrate a wordpress plugin called TaxJar which automatically calculates the necessary sales tax for our sales (and has a REST api). Now, if that doesn’t make sense and 4D can’t query this plugin in that sort of manner, then how can I create my own database of sales tax rates that will apply to different orders based on different zip codes.

Also for clarification, I am self taught in Python. But other than that my code experience is minimal.

let’s look at TaxJar.

They put up a sample python api call - https://github.com/taxjar/taxjar-python

Code :

import requests
headers = {“Authorization”: “Bearer YOUR_API_TOKEN”}
r = requests.get(‘https://api.taxjar.com/v2/rates/85040’, headers=headers)
r.json()
{u’rate’: {u’city’: u’PHOENIX’, u’zip’: u’85040’, u’combined_district_rate’: u’0.0’, u’state_rate’: u’0.056’, u’city_rate’: u’0.02’, u’county’: u’MARICOPA’, u’state’: u’AZ’, u’combined_rate’: u’0.083’, u’county_rate’: u’0.007’}}

in 4D (v15, because I have that open right now)

<code 4D>
c_text($url)
$url:=“https://api.taxjar.com/v2/rates/85040

ARRAY TEXT($header_name;0)
ARRAY TEXT($header_value;0)

APPEND TO ARRAY($header_name;“Authorization”)
APPEND TO ARRAY($header_value;“Bearer YOUR_API_TOKEN”)

C_OBJECT($response_object)

$status:=HTTP Get($url;$response_object;$header_name;$header_value)

</code 4D>

I can’t test it because I’ve not signed up for a token, but that’s the gist of it.