1

I am using third party API URL from NAV and it has predefined variable to be passsed in the API.

URL is something like this MAINAPIHOSTURL/PostedSalesHeaderAPI?$filter=No%20eq%20%27FZPSI-00010%27&$format=json

Here $filter and $format is predefine variable used in API section. when use like this in magento code it show error like Exception #0 (Exception): Notice: Undefined variable: filter

When i define it using below code like $filter = ''; $format = ''; in the function it passed empty in url so i am not able to get result from api call.

What can we do for this.

1 Answer 1

0

Oh, it was an ugly mistake from my side it definitely helps someone when his mind stops on this.

Here I have defined it like this.

<?php $url = "MAINAPIHOSTURL/PostedSalesHeaderAPI?$filter=No%20eq%20%27FZPSI-00010%27&$format=json" ?>

Here in URL $format and $filter will be parsed in PHP compiler as variable because we have used " to bind string but it gives notice when strict mode is enabled because it is not defined anywhere. so the solution is simple yet easy

we can pass it as follow so the PHP compiler considers it as a string not a variable.

<?php $url = "MAINAPIHOSTURL/PostedSalesHeaderAPI?".'$filter=No%20eq%20%27FZPSI-00010%27&$format=json';?>

Here we have to use ' to bind string so it will consider as a string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.