Все это прекрасно работает.
Однако теперь данные должны быть отправлены обратно в Wix, ожидая POST-запроса. И тут все начинает ломаться.
Данные отправляются, но не извлекаются WIX.
Итак, я попробовал отладить процедуру в виртуальной среде.
Следующее мой код Python в конце показывает данные для отправки, а также (измененный, то есть вымышленный) site_id, токен WIX API и идентификатор учетной записи wix.
Код: Выделить всё
# Data to be send and send back to Wix to the dedicated site
results = {
"SelfSufficiency": float(self_sufficiency),
"BatteryType": battery_type,
"BatteryCost": int(battery_cost),
"PaybackTime": float(payback_time)
}
headers = {
"Authorization": "Bearer IST.eyJ....", # My WIX API token
"wix-account-id": "12c....",
"Content-Type": "application/json"
}
# Sending data to the specific site on WIX website
site_id = "6b2cd5aa-...."
wix_url = f"https://www.wixapis.com/site-list/v2/sites/{site_id}/query"
# Log the payload and headers before sending
logging.debug(f"Sending payload to Wix: {results}")
logging.debug(f"With headers: {headers}")
response = requests.post(wix_url, headers=headers, json=results)
Код: Выделить всё
DEBUG:root:Sending payload to Wix: {'SelfSufficiency': 74.13495121509517, 'BatteryType': 'sonnenBattery10p/11', 'BatteryCost': 26000, 'PaybackTime': 9.3}
DEBUG:root:With headers: {'Authorization': 'Bearer IST.eyJr...', 'Content-Type': 'application/json'}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.wixapis.com:443
DEBUG:urllib3.connectionpool:https://www.wixapis.com:443 "POST /site-list/v2/sites/e6e64d9d-b3ff-4e.../query HTTP/11" 302 293
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): users.wix.com:443
DEBUG:urllib3.connectionpool:https://users.wix.com:443 "GET /signin?originUrl=https%3A%2F%2Fwww.wixapis.com%2Fsite-list%2Fv2%2Fsites%2Fe6e64d9d-b3ff-4e5d-b842-d0dd5c045698%2Fquery&redirectTo=https%3A%2F%2Fwww.wixapis.com%2Fsite-list%2Fv2%2Fsites%2Fe6e64d9d-b3ff-4e5d-b842-d0dd5c045698%2Fquery&overrideLocale=en HTTP/11" 302 0
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): users.editorx.com:443
DEBUG:urllib3.connectionpool:https://users.editorx.com:443 "GET /auth/getssomagiclink?originUrl=https%3A%2F%2Fwww.wixapis.com%2Fsite-list%2Fv2%2Fsites%2Fe6e64d9d-b3ff-4e5d-b842-d0dd5c045698%2Fquery&redirectTo=https%3A%2F%2Fwww.wixapis.com%2Fsite-list%2Fv2%2Fsites%2Fe6e64d9d-b3ff-4e5d-b842-d0dd5c045698%2Fquery&overrideLocale=en HTTP/11" 302 0
DEBUG:urllib3.connectionpool:https://users.wix.com:443 "GET /signin?originUrl=https%3A%2F%2Fwww.wixapis.com%2Fsite-list%2Fv2%2Fsites%2Fe6e64d9d-b3ff-4e5d-b842-d0dd5c045698%2Fquery&redirectTo=https%3A%2F%2Fwww.wixapis.com%2Fsite-list%2Fv2%2Fsites%2Fe6e64d9d-b3ff-4e5d-b842-d0dd5c045698%2Fquery&overrideLocale=en&forceRender=true HTTP/11" 400 None
ERROR:root:Failed to send data to Wix:
angular.module('wixErrorPagesApp').constant('staticsUrl', '//static.parastorage.com/services/wix-public/1.719.0/');
angular.module('wixErrorPagesApp').constant('baseDomain', 'wix.com');
angular.module('wixErrorPagesApp').constant('language', 'en');
angular.module('wixErrorPagesApp').constant('errorCode', {code: '400'});
angular.module('wixErrorPagesApp').constant('data', {});
angular.module('wixErrorPagesApp').constant('exceptionName', '');
angular.module('wixErrorPagesApp').constant('serverErrorCode', '-15008');
angular.module('wixErrorPagesApp').constant('requestId', '1722231783.87325224461548821016');
INFO:werkzeug:127.0.0.1 - - \[29/Jul/2024 07:23:53\] "POST /webhook HTTP/1.1" 500 -
ERROR:root:Error in webhook processing: float() argument must be a string or a real number, not 'NoneType'
INFO:werkzeug:127.0.0.1 - - \[29/Jul/2024 23:47:08\] "POST /webhook HTTP/1.1" 500 -
Спасибо за ответы!
Подробнее здесь: https://stackoverflow.com/questions/788 ... ix-website