artaylor Posted May 1, 2019 Share Posted May 1, 2019 Hi, I have a site the interfaces with a payment processor. As transactions happen on the processor, it automatically calls endpoints on my application and passes a JSON body with the details. Working for a few hours with the payment processor support team we have figured out that the problem is the the endpoint is returning a 301 which they cannot handle. It is also converting the POST to a GET. I thought it was due to the PagePathHistory module as at one point I did move the page to a new location in the tree. However, I have since then tried the following: Moved it back to the original place. Deleted and recreated Deleted and changed the name Truncated the page_path_history table in the database However, I am still getting a 301 and my log file still shows a GET request. Here is the code for the New Subscription endpoint wire()->log()->save('ccbill', 'Add New Subscription Started'); wire()->log()->save('ccbill', 'Request Method: ' . $_SERVER['REQUEST_METHOD']); $ccBillData = json_decode(file_get_contents('php://input'), true); // get the JSON encoded data and convert to PHP array if ($ccBillData !== NULL) wire()->log()->save('ccbill', "Data: " . var_dump($ccBillData)); $ccBillIntegration = modules()->get('CcbillIntegration'); $ccBillIntegration->addNewSubscription($ccBillData); And the results in the log file when I use an API Tester to POST to the endpoint with some JSON 2019-04-30 22:41:51 guest http://site/subscription-new/ Add New Subscription Started 2019-04-30 22:41:51 guest http://site/subscription-new/ Request Method: GET Any and all help is appreciated. I have no hair left to pull out... Link to comment Share on other sites More sharing options...
Robin S Posted May 1, 2019 Share Posted May 1, 2019 16 minutes ago, artaylor said: the problem is the the endpoint is returning a 301 A couple of things to check: That you are calling the endpoint URL with/without a trailing slash according to the template "Should page URLs end with a slash?" setting. If the site is multi-language that you are calling the endpoint URL with the language string in it, e.g. http://site/en/subscription-new/ 2 Link to comment Share on other sites More sharing options...
artaylor Posted May 1, 2019 Author Share Posted May 1, 2019 @Robin S Adding the slash at the end worked. You rock and my remaining strand of hair thanks you immensely for your prompt, working reply! 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now