Error on API Connection Status
-
Hi Support,
My client is having this issue with their website where the status of API connection is [XML2Array] Error parsing the XML string.
Please explain why and kindly provide some guidelines on how to solve it.
Thank you.
-
I am experiencing this as well. I was using the a different plugin that also stopped working so decided to give this one a try and am getting this error.
Please enable debug mode and paste here API request and response: https://octolize.com/docs/article/usps-general-settings/#debug_mode
I enabled debugging and the only thing I am getting is “USPS Live Rates: [XML2Array] Error parsing the XML string.”
I have disabled my cloudflare proxy, and I am also experiencing similar results with other USPS calculator plugins. I have tested my USPS API username and verified it is correct by doing a request to https://secure.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=%3CRateV4Request%20USERID=%22MY_ID_HERE%22%20PASSWORD=%22%22%3E%3CRevision%3E2%3C/Revision%3E%3CPackage%20ID=%221ST%22%3E%20%3CService%3EGROUND%20ADVANTAGE%3C/Service%3E%20%3CZipOrigination%3E30677%3C/ZipOrigination%3E%20%3CZipDestination%3E46750%3C/ZipDestination%3E%20%3CPounds%3E0%3C/Pounds%3E%20%3COunces%3E10%3C/Ounces%3E%20%3CContainer%3EVARIABLE%3C/Container%3E%20%3CWidth%3E%3C/Width%3E%20%3CLength%3E%3C/Length%3E%20%3CHeight%3E%3C/Height%3E%20%3CMachinable%3E%3C/Machinable%3E%20%3CDropOffTime%3E%3C/DropOffTime%3E%20%3CShipDate%3E2023-11-20%3C/ShipDate%3E%20%3CSortationLevel%3E%3C/SortationLevel%3E%20%3CDestinationEntryFacilityType%3E%3C/DestinationEntryFacilityType%3E%20%3CReturnFees%3Etrue%3C/ReturnFees%3E%20%3C/Package%3E%20%3C/RateV4Request%3E which does work.
In my Nginx log I am getting
2023/11/18 16:19:55 [error] 1581#1581: *346 FastCGI sent in stderr: "PHP message: PHP Warning: DOMDocument::loadXML(): Start tag expected, '<' not found in Entity, line: 1 in /home/runcloud/webapps/altman/wp-content/plugins/flexible-shipping-usps/vendor_prefixed/vinceg/usps-php-api/src/XML2Array.php on line 55" while reading response header from upstream, client: 66.153.189.27, server:redacted.com, request: "GET /checkout/ HTTP/2.0", upstream: "fastcgi://unix:/var/run/altman.sock:", host: "redacted.com", referrer: "https://redacted.com/cart/"I’m sorry it actually is showing the debug boxes and the request is:
<?xml version="1.0" encoding="UTF-8"?> <RateV4Request USERID="MY_ID_HERE"> <Revision>2</Revision> <Package ID="1"> <Service>ONLINE</Service> <ZipOrigination>29578</ZipOrigination> <ZipDestination>29566</ZipDestination> <Pounds>0</Pounds> <Ounces>6</Ounces> <Container></Container> <Machinable>true</Machinable> </Package> </RateV4Request>The endpoint URL is: https://secure.shippingapis.com/ShippingAPI.dll
Sorry for the deluge of responses. When I try and submit that as a manual GET request (with my ID of course) I get an authentication error, but when I add PASSWORD=”” after USERNAME it works successfully.
Perhaps the hosting has turned on some firewall. I just checked our demo site and everything works fine. You can also test it at https://demo.octolize.com/
The Password=”” wasn’t correct as it does work without it. The hosting is a VPS and I have disabled Wordfence and cloudflare but the strange thing is that curl requests from the server cli to the same URL that works in my browser are actually returning a binary response instead of text/xml.
Edit: the binary is actually just gzip compression
-
This reply was modified 2 years, 6 months ago by
Clint Johnson.
I think I am getting somewhere. USPS may be blocking Digital Ocean IPs? I have tried from 3 different Ubuntu servers on Digital Ocean and all have returned a 401 Unauthorized response. The same curl request from my ubuntu home lab server, 2 different Azure Ubuntus, and a hosted postman instance are all successful.
Confirmed: I cloned my site through runcloud to one of my Azure servers and it now works.
-
This reply was modified 2 years, 6 months ago by
Clint Johnson.
@nmbgeek can you check curl with “Accept-Encoding: identity” header?
Same thing. It works on my Azure and home lab but on 3 different digital ocean servers I receive a binary response and if I add “–compressed” the 403 response “You do not have permission to access this page
If you have found this page in error, please contact support”. Can’t even put in a support request to USPS because once I submit I get an error back as well.Also having this issue on a DigitalOcean-hosted site. Anyone have any success with getting in touch with the USPS API team?
I am using a Droplet on Digital Ocean running Ubuntu 22.04.2 LTS and yesterday I was successful in configuring USPS Live Rates.
API Connection Status OK -
This reply was modified 2 years, 6 months ago by
The topic ‘Error on API Connection Status’ is closed to new replies.