Home > Software engineering >  getting error Failed to execute 'fetch' on 'Window': Invalid name
getting error Failed to execute 'fetch' on 'Window': Invalid name

Time:06-30

I am trying to publish API in wso2 API Manager. But I am using basic security with my authorization key. I am getting a type error: Failed to execute 'fetch' on 'Window': Invalid name. I tried to change the swagger file. But didn't get the required response.

CodePudding user response:

If you are trying to send a header to your backend through APIM, you have define it as a header under resources in the Publisher portal.

However, if the name of your header is Authorization you will have to use some sort of a mediation to send this to your backend. For example,

<sequence xmlns="http://ws.apache.org/ns/synapse" name="KeyExchange">
    <property name="Custom" expression="get-property('transport', 'Custom')"/>
    <property name="Authorization" expression="get-property('Custom')" scope="transport"/>
    <property name="Custom" scope="transport" action="remove"/>
</sequence>

If you add the above to your in-sequences, you will have to send a header called Custom with the key you need to send to the backend. Then APIM will replace this Custom header with Authorization header when sending the request out from APIM.

If you have enabled Basic auth for your API created in APIM, you need to follow [1] to invoke the API.

  • Related