akeneo / api-php-client

PHP client of Akeneo PIM API

Home Page:https://packagist.org/packages/akeneo/api-php-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP issue on Next page

padmapriya-varadhan opened this issue · comments

While working on the imports, we noticed that the Categories, Options and Attribute imports did not import any data and stopped abruptly with a message "Found". On narrowing down the issue, we found that the "Found" message was actually an exception with HTTP code 302. The response body for HTTP code 302 was "Found" and hence this was printed on the import screen.
The “Found” exception that was thrown for categories, attribute and options import was caused while accessing data from the ‘Next’ page. The response received was 302 Found and it was considered as an Exception in PIM as RedirectionHttpException. We suspect the reason to be the HTTP client tries to redirect the http URL to https URL. The issue did not happen while fetching the first page content and it fetched up to the maximum limit 100 because the request for the first page had a https URL.

Please find below a screenshot of the request and response that we got for Page 2.
image

image

Below is the request and response that we got for Page 1:
image

image

We had fixed the issue by changing the url from http to https on \app\code\Akeneo\Pim\src\Pagination\Page.php : Line no: 134
image

After adding the above fix, we were able to retrieve data from all pages (records > 100 are split into pages) from the imports.

Hello,
All API urls are managed by Symfony router and HTTPS links will be generated if running on a https server.The case you describe make me think of an API running through some kind of proxy or load balancer.

Could you check this article about working with this kind of architecture and check if it relates to your architecture: https://symfony.com/doc/current/deployment/proxies.html

Youc could also have a look to this related article: https://symfony.com/doc/current/security/force_https.html

Regards,
JM

I will close this issue. Do not hesitate to reopen it if needed.

Same happening on my Akeneo, I followed all the steps that you have mentioned regarding Symfony's docs and none of them worked.

In addition, in my case Akeneo is running over SSL and each one URL given for pagination in the responses are assuming it, it's always considering HTTP.

Any idea how to fix without hardcoding HTTPS instead HTTP?

Same happening on my Akeneo, I followed all the steps that you have mentioned regarding Symfony's docs and none of them worked.

In addition, in my case Akeneo is running over SSL and each one URL given for pagination in the responses are assuming it, it's always considering HTTP.

Any idea how to fix without hardcoding HTTPS instead HTTP?

I'm also having the same issue, did you ever get the problem figured out? The solution provided by padmapriya-varadhan of doing an str_replace... works... but is less then optimal, since it involves modifiying code that gets overwritten when you update vendors for example.

Thanks in advance