SoftLayer API returns text instead of json?

Viewed 536

I've been using an api with curl as follows: curl -X GET -g -u $SL_USER:$SL_APIKEY "https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getHardware and I used to get json response:

{"accountId":1414807,"bareMetalInstanceFlag":0,"domain":"regtech.cloud.com","fullyQualifiedDomainName":"dal1302vsrx001.regtech.cloud.com","hardwareStatusId":5,"hostname":"dal1302vsrx001","id":1579801,"manufacturerSerialNumber":"C819UAH12CC0374","notes":"","provisionDate":"2020-02-19T17:16:02-06:00","serialNumber":"SL01HOPT","serviceProviderId":1,"serviceProviderResourceId":null,"globalIdentifier":"957011c1-126f-4cc9-9c95-b7470f05d238","hardwareFunction":{"code":"WEBSVR","description":"Web Server","id":3},"hardwareStatus":{"id":5,"status":"ACTIVE"},"networkManagementIpAddress":"10.220.221.231","primaryBackendIpAddress":"10.220.221.222","primaryIpAddress":"55.517.245.230","privateIpAddress":"10.220.221.222"}

Now, I'm trying to reimplement this in axios js and I get text by default. I tried to explicitly set response-type to json but not working! Please help if you see something wrong I made in the code below:

api_endpoint="https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getHardware"
axios.get(api_endpoint, {
    params:{
        resultLimit: 1
    },
    auth: {
        username: SL_USER,
        password: SL_APIKEY
    },
    responseType: 'application/json',
    timeout: 20000
})
.then((response) => {
    console.log(response.data)
})
.catch(function (ex) {
    console.log("There was an error obtaining the product id")
    console.log(ex)
})

Here's the format I get from axios code:

META_PROPERTIES='ACCOUNT_ID BARE_METAL_INSTANCE_FLAG DOMAIN FULLY_QUALIFIED_DOMAIN_NAME HARDWARE_STATUS_ID HOSTNAME ID MANUFACTURER_SERIAL_NUMBER NOTES PROVISION_DATE SERIAL_NUMBER SERVICE_PROVIDER_ID SERVICE_PROVIDER_RESOURCE_ID GLOBAL_IDENTIFIER HARDWARE_FUNCTION HARDWARE_STATUS NETWORK_MANAGEMENT_IP_ADDRESS PRIMARY_BACKEND_IP_ADDRESS PRIMARY_IP_ADDRESS PRIVATE_IP_ADDRESS'
META_PROPERTY_TYPES='SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR SCALAR OBJECT OBJECT SCALAR SCALAR SCALAR SCALAR'

ACCOUNT_ID='1414807'
BARE_METAL_INSTANCE_FLAG='0'
DOMAIN='regtech.cloud.com'
FULLY_QUALIFIED_DOMAIN_NAME='dal1302vsrx001.regtech.cloud.com'
.
.
.

1 Answers

I added .json to the end of my url.

enter image description here

Related