Solução de problemas de erro na implantação da política HTTPModifier
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Você está
vendo a documentação da Apigee X.
Veja a documentação da Apigee Edge.
InvalidIndex
Mensagem de erro
A implantação do proxy de API por meio da IU da Apigee ou da API falha com esta mensagem de erro:
Error in deployment for environment [environment]
The revision is deployed, but traffic cannot flow.
AssignMessage[policy_name]: index must be greater than zero in [attribute].[index]
Se o índice especificado nos elementos <Copy> e/ou <Remove> da política HTTPModifier for 0 ou um número negativo, a implantação do proxy de API falhará.
Por exemplo, se você passar vários parâmetros de consulta com o mesmo nome, poderá acessá-los como variáveis de fluxo indexadas. Digamos que você queira passar os IDs de três alunos como parâmetros de consulta. Faça isso da seguinte maneira:
Digamos que você tente acessar esses parâmetros de consulta com os números de índice 0, 1 e 2 na política HTTPModifier da seguinte maneira:
id.0
id.1 and
id.2
Nesse caso, a implantação do proxy falha porque o índice precisa começar com 1. Isso significa que você pode acessar o primeiro parâmetro de consulta "id=1" como "id.1". Para acessar o segundo parâmetro de consulta "id=2", você precisa usar o índice 2, ou seja, "id.2". Da mesma forma, para acessar o terceiro parâmetro de consulta "id=3", é possível usar "id.3".
Identifique a política HTTPModifier em que o erro ocorreu, o nome do atributo e o índice inválido. Você pode encontrar todos esses itens na mensagem de erro. Por exemplo, no erro a seguir, o nome da política é GeneratingGeocodingRequest, o nome do atributo é id e o índice é 0:
Verifique se o nome do atributo e o índice usados no XML da política HTTPModifier com falha correspondem ao nome do atributo e ao índice identificados na mensagem de erro (etapa 1 acima). Por exemplo, a política a seguir especifica o atributo id e o índice como 0, que corresponde ao que está na mensagem de erro:
Se o índice especificado for 0 ou um número negativo, essa será a causa do erro.
No exemplo da política "Atribuir mensagem" mostrada acima, você está tentando acessar o primeiro valor do parâmetro de consulta "id" usando o índice 0. Portanto, a implantação do proxy de API falha com o erro:
Em HTTPModifier, ao acessar vários cabeçalhos, parâmetros de consulta ou outros parâmetros com o mesmo nome, verifique se o índice é sempre maior que zero. Exemplo:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[[["\u003cp\u003eAPI proxy deployment in Apigee X can fail with an "index must be greater than zero" error when using the HTTPModifier policy.\u003c/p\u003e\n"],["\u003cp\u003eThis error occurs if the \u003ccode\u003e<Copy>\u003c/code\u003e or \u003ccode\u003e<Remove>\u003c/code\u003e elements within the HTTPModifier policy attempt to access indexed flow variables with an index of 0 or a negative number.\u003c/p\u003e\n"],["\u003cp\u003eThe index in the HTTPModifier policy, when dealing with parameters that share the same name, must start at 1, not 0.\u003c/p\u003e\n"],["\u003cp\u003eTo resolve this, verify the index in the failing HTTPModifier policy, ensure that it is a positive number greater than zero, and adjust the index accordingly in the policy definition.\u003c/p\u003e\n"]]],[],null,["# HTTPModifier policy deployment error troubleshooting\n\n*You're viewing **Apigee X** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/troubleshoot/policies/deployment/assign-message-deployment-errors) documentation.*\n| Was this troubleshooting playbook helpful? Please let us know by clicking [Send Feedback]().\n\nInvalidIndex\n------------\n\n### Error message\n\nDeployment of the API proxy through either the Apigee UI or API fails with this error message: \n\n```\nError in deployment for environment [environment]\nThe revision is deployed, but traffic cannot flow.\nAssignMessage[policy_name]: index must be greater than zero in [attribute].[index]\n```\n\n**Example error message** \n\n Error in deployment for environment test.\n The revision is deployed, but traffic cannot flow.\n HTTPModifier[GenerateStudentsRequest]: index must be greater than zero in id.0\n\n### Cause\n\nIf the index specified in the `\u003cCopy\u003e` and/or `\u003cRemove\u003e` elements of the HTTPModifier policy is 0 or a negative number, then deployment of the API Proxy fails.\n\nFor example, if you pass multiple query parameters with the same name, you can access them as indexed flow variables. Let's say you want to pass the IDs of 3 students as query parameters, then you can do it as follows: \n\n https://$EXTERNAL_IP/$PROXY_BASEPATH?school_name=NPS&id=1&id=2&id=3\n\nThen, let's say you attempt to access these query parameters with index numbers 0, 1, and 2 in the HTTPModifier policy as follows: \n\n id.0\n id.1 and\n id.2\n\nIn this case, the deployment of the proxy fails because the index must start with 1. This means, you can access the first query parameter \"id=1\" as \"id.1\". To access the second query parameter \"id=2\", you need to use the index 2 i.e, \"id.2\". Similarly, to access the third query parameter \"id=3\", you can use \"id.3\".\n\nFor more information, see the [AssignMessage policy Copy element documentation](/apigee/docs/api-platform/reference/policies/assign-message-policy#copy).\n\n### Diagnosis\n\n1. Identify the HTTPModifier policy where the error occurred, the name of the attribute, and the invalid index. You can find all these items in the error message. For example, in the following error, the policy name is `GeneratingGeocodingRequest`, the name of the attribute is `id`, and the index is `0`:\n\n HTTPModifier[GenerateStudentsRequest]: index must be greater than zero in id.0\n\n2. Verify that the attribute name and the index used in the failed HTTPModifier policy XML matches the attribute name and the index identified in the error message (step #1 above). For example, the following policy specifies the attribute `id` and index as `0`, which matches what's in the error message:\n\n ```carbon\n \u003cAssignMessage name=\"GenerateStudentsRequest\"\u003e\n \u003cAssignTo createNew=\"true\" type=\"request\"\u003eStudentsInfoRequest\u003c/AssignTo\u003e\n \u003cCopy source=\"request\"\u003e\n \u003cQueryParams\u003e\n \u003cQueryParam name=\"school_name\"/\u003e\n \u003cQueryParam name=\"id.0\"/\u003e\n \u003cQueryParam name=\"id.1\"/\u003e\n \u003cQueryParam name=\"id.2\"/\u003e\n \u003c/QueryParams\u003e\n \u003c/Copy\u003e\n \u003c/AssignMessage\u003e\n ```\n3. If the index specified is 0 or negative number, then that's the cause of the error.\n\n In the example Assign Message policy shown above, you are trying to access the first value of the query parameter \"id\" using the index 0. Hence the deployment of the API Proxy fails with the error: \n\n AssignMessage[GenerateStudentsRequest]: index must be greater than zero in id.0\n\n### Resolution\n\nIn HTTPModifier, when you access multiple headers, query parameters, or other parameters that share the same name, ensure that the index is always greater than zero. For example: \n\n \u003cAssignMessage name=\"GenerateStudentsRequest\"\u003e\n \u003cAssignTo createNew=\"true\" type=\"request\"\u003eStudentsInfoRequest\u003c/AssignTo\u003e\n \u003cCopy source=\"request\"\u003e\n \u003cQueryParams\u003e\n \u003cQueryParam name=\"school_name\"/\u003e\n \u003cQueryParam name=\"id.1\"/\u003e\n \u003cQueryParam name=\"id.2\"/\u003e\n \u003cQueryParam name=\"id.3\"/\u003e\n \u003c/QueryParams\u003e\n \u003c/Copy\u003e\n \u003c/AssignMessage\u003e"]]