Ricky Levi
Ricky Levi

Reputation: 7987

aliyun GetPayAsYouGoPrice fails on Module.Config value due to semicolon

I want to query GetPayAsYouGoPriceRequest per document: https://www.alibabacloud.com/help/en/bss-openapi/latest/getpayasyougoprice

Before querying it - i need to query both QueryProductList & DescribePricingModule - they are running OK.

But the problem is that GetPayAsYouGoPrice result an error:

{
"RequestId":"7A...",
"HostId":"business.ap-southeast-1.aliyuncs.com",
"Code":"InvalidParameter",
"Message":"The specified parameter Module.Config's format should be moduleCode1:value1,moduleCode2:value2.... config: Bandwidth:1024-204800:1024, moduleCode: Bandwidth",
"Recommend":"https://next.api.aliyun.com/troubleshoot?q=InvalidParameter&product=BssOpenApi"}

The values returned from DescribePricingModule ( AttributeList ) has the following key/value:

Key=Bandwidth

Value[0]="1024-204800:1024"
Value[1]="204800-512000:1024"
etc...

This value contains : in it which confuse the API query string when parsed probably in the backend, my query string parameter is:

&ModuleList.4.Config=Bandwidth:1024-204800:1024,ISP:BGP,InternetChargeType:0,Region:ap-northeast-2

But this is what we receive from the API, I didn't invent it - so what is expected to do here ?

Attaching code snippets

QueryProductList

1st API call towards querying the product structure

# product_code="eip"
def query_product_list(product_code):
    request = QueryProductListRequest()
    request.add_query_param('ProductCode', product_code)
    request.add_query_param('PageNum', 1)
    request.set_accept_format('json')

    response = client.do_action_with_exception(request).decode('utf8')

# Output
[{'SubscriptionType': 'PayAsYouGo', 'ProductName': 'EIP', 'ProductCode': 'eip', 'ProductType': ''},
 {'SubscriptionType': 'Subscription', 'ProductName': 'EIP(Subscription)', 'ProductCode': 'eip', 'ProductType': ''}]

DescribePricingModule

2nd API call to get the description of the pricing based on the product

request = DescribePricingModuleRequest()
request.set_accept_format('json')

request.add_query_param('ProductType', '')
request.add_query_param('ProductCode', 'eip')
request.add_query_param('SubscriptionType', 'PayAsYouGo')
response = client.do_action_with_exception(request).decode('utf8')

# Output
# The output here is huge, so i'll just show the parts related to the Bandwidth
'Data': {
    'AttributeList': {
      'Attribute': [{
          'Values': {
            'AttributeValue': [
              {
                'Type': 'range_float',
                'Value': '1024-204800:1024',
                'Name': '1_200'
              },
              {
                'Type': 'range_float',
                'Value': '1024-512000:1024',
                'Name': '1_500'
              },
              {
                'Type': 'range_float',
                'Value': '204800-512000:1024',
                'Name': '200_500'
              },
              {
                'Type': 'range_float',
                'Value': '5120-5120:1024',
                'Name': '5_5'
              },
              {
                'Type': 'range_float',
                'Value': '10240-512000:1024',
                'Name': '10_500'
              },
              {
                'Type': 'range_float',
                'Value': '51200-512000:1024',
                'Name': '5_500'
              },
              {
                'Type': 'range_float',
                'Value': '10240-10240:1024',
                'Name': '10_10'
              },
              {
                'Type': 'range_float',
                'Value': '1024-3072000:1024',
                'Name': '1_3000'
              }
            ]
          },
          'Unit': 'Kbps',
          'Code': 'Bandwidth',
          'Name': '带宽峰值'
        }]
    },
    'ModuleList': {
      'Module': [
        {
          'ModuleCode': 'Bandwidth',
          'ModuleName': '带宽峰值',
          'Currency': 'USD',
          'PriceType': 'Day',
          'ConfigList': {
            'ConfigList': [
              'Bandwidth',
              'ISP',
              'Region',
              'InternetChargeType'
            ]
          }
        }
      ]
    }
  },

Upvotes: 0

Views: 42

Answers (0)

Related Questions