0
votes

I am using SoftLayer GO API client library to order endurance volumes from the link https://github.com/softlayer/softlayer-go

I am facing issue with PlaceOrder API

Please find the error message below:

2016/11/22 23:54:51 [DEBUG] Path: https://api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json 2016/11/22 23:54:51 [DEBUG] Parameters: {"parameters":[{"ComplexType":"SoftLayer_Container_Product_Order"}]} 2016/11/22 23:54:51 [DEBUG] Response: {"error":"The property 'ComplexType' is not valid for 'SoftLayer_Container_Product_Order'.","code":"SoftLayer_Exception_Public"} SoftLayer_Exception_Public: The property 'ComplexType' is not valid for 'SoftLayer_Container_Product_Order'. (HTTP 500)

I have given ComplexType property with correct value.

1
Post your GO code, it is imposible to help you without the code. Currently seeing the debug log it seems you are only sending the "ComplexType" property which is wrong even if you use a RESTFul call you will get the same error. - Nelson Raul Cabero Mendoza

1 Answers

0
votes

Well I do not have idea about your code but I was able to make the verifyOrder works to order endurance volumes

package main

import (
    "fmt"
    //"log"

    "github.com/softlayer/softlayer-go/datatypes"
    "github.com/softlayer/softlayer-go/services"
    "github.com/softlayer/softlayer-go/session"
    "github.com/softlayer/softlayer-go/sl"
)

func main() {
    sess := session.New() // See above for details about creating a new session

    // Get the Virtual_Guest service
    service := services.GetProductOrderService(sess)

    // Create a Virtual_Guest struct as a template
    vOrderTemplate := datatypes.Container_Product_Order_Network_Storage_Enterprise{}
    vOrderTemplate.Location = sl.String("154820")
    vOrderTemplate.Quantity = sl.Int(1)
    vOrderTemplate.PackageId = sl.Int(240)


    price1 := datatypes.Product_Item_Price{}
    price1.Id = sl.Int(45058)

    price2 := datatypes.Product_Item_Price{}
    price2.Id = sl.Int(45098)

    price3 := datatypes.Product_Item_Price{}
    price3.Id = sl.Int(45068)

    price4 := datatypes.Product_Item_Price{}
    price4.Id = sl.Int(45118)

    price5 := datatypes.Product_Item_Price{}
    price5.Id = sl.Int(46120)

    prices := []datatypes.Product_Item_Price{price1,price2,price3,price4,price5}


    vOrderTemplate.Prices = prices

    vOrderTemplate.OsFormatType = &datatypes.Network_Storage_Iscsi_OS_Type{
                                    Id: sl.Int(12),
                                    KeyName:  sl.String("LINUX"),
                                 }


    vOrd, err := service.VerifyOrder(&vOrderTemplate)


   if err != nil {
        fmt.Printf("%s\n", err)
        return
   } else {
        fmt.Printf("\norder verified with Total Recurring Tax %d\n", *vOrd.TotalRecurringTax)
   }

}

I am new with GO, so sorry if the code is not quite simple :P, Also I did not know how to print all the properties of the response so I've only printed one property.As you may be an expert in GO I am sure you can improve the code.

Note make sure that you are using the correct prices in the order.

My code in Go basically is the same like a RESTFul call like this:

{
  "parameters": [
    {
      "location": 154820,  //Dallas 06
      "packageId": 240,
      "osFormatType": {
        "id": 12,
        "keyName": "LINUX"
      },
      "complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise",
      "prices": [
        {
          "id": 45058   # Endurance Storage
        },
        {
          "id": 45098   # Block Storage
        },
        {
          "id": 45068   # 0.25 IOPS per GB
        },
        {
          "id": 45118   # 20 GB Storage Space
        },
        {
          "id": 46120   # 5 GB Storage Space - Snapshot
        }
      ],
      "quantity": 1
    }
  ]
}

Regards