az apim import graphql using specification path fails with 'link' is not a valid absolute URI
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### Describe the bug
I am trying to import a GraphQL specification from file into API Management.
When running:
```
az apim api import --path $apiPath --resource-group $resourceGroup `
--service-name $apiManagementName --api-id $apiId `
--api-type graphql `
--specification-format "GraphQL" `
--service-url "https://contoso.com" `
--display-name $displayName --specification-format "GraphQL" --specification-path "./schema.gql"
```
My GraphQL file looks as follows:
``` graphql
schema {
query: AssetQuery
}
type AssetQuery {
hello: String
}
```
I think I found the issue, however can't validate. Please check the linked commit / pull request.
### Related command
az apim api import
### Errors
using PowerShell v7.4.6, I always run into following issue (no matter the graphql schema):
```
Exception Details: (ValidationError) Parsing error(s): 'link' is not a valid absolute URI. Path: link.
Code: ValidationError
Message: Parsing error(s): 'link' is not a valid absolute URI. Path: link.
Target: representation
```
### Issue script & Debug output
az apim api import --path $apiPath --resource-group $resourceGroup `
--service-name $apiManagementName --api-id $apiId `
--api-type graphql `
--specification-format "GraphQL" `
--service-url "https://contoso.com" `
--display-name $displayName --specification-format "GraphQL" --specification-path "./schema.gql"
```
cli.azure.cli.core.sdk.policies: {"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"representation","message":"Parsing error(s): 'link' is not a valid absolute URI. Path: link."}]}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 664, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 701, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 334, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/apim/custom.py", line 510, in apim_api_import
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 710, in sdk_no_wait
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/tracing/decorator.py", line 76, in wrapper_use_tracer
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/apimanagement/operations/_api_operations.py", line 890, in begin_create_or_update
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/apimanagement/operations/_api_operations.py", line 727, in _create_or_update_initial
azure.core.exceptions.HttpResponseError: (ValidationError) One or more fields contain incorrect values:
Code: ValidationError
Message: One or more fields contain incorrect values:
Exception Details: (ValidationError) Parsing error(s): 'link' is not a valid absolute URI. Path: link.
Code: ValidationError
Message: Parsing error(s): 'link' is not a valid absolute URI. Path: link.
Target: representation
```
### Expected behavior
The graphql API gets imported properly.
### Environment Summary
azure-cli 2.65.0
core 2.65.0
telemetry 1.1.0
Extensions:
containerapp 1.0.0b3
durabletask 1.0.0b1
Dependencies:
msal 1.31.0
azure-mgmt-resource 23.1.1
Python location '/opt/az/bin/python3'
Extensions directory '/home/***/.azure/cliextensions'
Python (Linux) 3.11.8 (main, Sep 25 2024, 11:33:44) [GCC 11.4.0]
Legal docs and information: aka.ms/AzureCliLegal
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.