Softlayer GET API "VirtualGuests" response too big - api

I am trying to do a GET operation on
GET https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests?objectMask=powerState%3BoperatingSystem.passwords%3Bdatacenter%3BbillingItem%3BblockDevices.diskImage%3BtagReferences
> Headers: Authorization: Accept : application/json
Response:
{
"error": "Internal Error",
"code": "SoftLayer_Exception_Public"
}
I found out that the results is too big, If I do a resultLimit on the API it works.
My question is, I have instance Id with me how Can I include it in the above API. I tried adding &id=XXXXXX at the end of the API it didn't work

I think you want to get only the data which contains the instance with ID correct?
well if you want the VM whose id = instace ID you can use the Softlayer_Virtual_Guest::getObject method instead Softlayer_Account::getVirtualGuests
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getObject
If you are looking for something more complex you can try objectFilters
https://sldn.softlayer.com/article/object-filters
if you have more questions let me know.

Related

UPDATE and REVISE rest api is not working in vTiger CRM cloud service

So basically I need to use the update/revise Rest API to update the fields in the vTiger CRM.
But when I am using the rest API (link : https://help.vtiger.com/article/147111249-Rest-API-Manual) to update the fields, I am getting the error as "400 Unsupported operations: The request cannot be fulfilled due to bad syntax."
My api : endpoint/reviseelement=convert_into_json_string({id:5x369, potentialname:'demo2'})
Also apart from this, I had used the SQL query Rest API, to update the record in the modules, but it is also giving me the same error as: "400 Unsupported operations: The request cannot be fulfilled due to bad syntax."
My Api query : endpoint/query?query=UPDATE Potentials SET potentialname = 'demo2 where id = 5x369;
Also by using the webservice(https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html) rest api I am getting error like : "Permission to perform the operations is denied for id: ".
So how can I use the update api. Can anyone please help?
For web services API (https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html),
When you pass the payload data, make sure you're passing the x-www-form-urlencoded form of data.
Also, make sure you're passing 'element' argument with value like this:
{"id": "10x11471458", "leadsource": "Facebook"}.
if you're still facing this issue, you can share more details and I'll be happy to help you.
If you still need to do this the following should work.
Method: POST
End Point: /revise
Headers: "Authorization: Basic YOUR_TOKEN"
Body:
{
"element": {
"id":"5x369",
"potentialname": "demo2"
}
}
reference: https://www.vtiger.com/docs/rest-api-for-vtiger#/Revise

How to Emulate a POST Request from PostMan - For a series of Integration Tests in a WebAPI Development

I am using PostMan as part of the testing regime for a WebAPI service development that I am working on. In order for external parties to gain access to our WebAPI service they first need to obtain an access token.
The POST request returns some JSON containing the required access token:
{
"access_token": "anencryptedaccesstoken",
"scope": "am_application_scope default",
"token_type": "Bearer",
"expires_in": 3218
}
I am putting together a series of integration tests which need to emulate the POST calls from POSTMAN. I am currently using System.Net.WebClient to achieve this. I am not sure what I need to do in order to achieve my goal. Here is a function that I am using to try and obtain the access token:
Public Shared Function GetAccessToken(ByVal endpoint As String, wc As WebClient) As String
Dim result As String = ""
Dim data As Byte() = Nothing
'Header information
wc.Headers.Add("Authorization", "Basic <alongencryptedstring>")
wc.Headers.Add("Content_Type", "application/x-www-form-urlencoded")
result = wc.UploadString(endpoint, "POST", "")
Return result
End Function
The 'Body' tab in PostMan contains the following entries:
grant_type - client_credentials
Content_Type - application%2Fx-www-form-urlencoded
In this instance as far as I am aware there is no 'data' element to the PostMan request hence the empty string in my use of UploadString. The function returns the following error:
"The remote server returned an error: (415) Unsupported Media Type."
I am new to web app development so please bear with me, I am finding it difficult to phrase what I think are meaningful question in the context of this post, I hope however that I have ssupplied sufficient information to convey the gist of my problem and for someone to be able to respond appropriately.
Kind Regards
Paul.

Google Sheet API batchUpdateByDataFilter PHP Function

https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdateByDataFilter
We have used above function in our code, while we are passing the more than 50 or 100 records within the array records then given 400 bad request array in response.
Can anyone describe the limit of the total values that we are going to pass within the above function?
Here is my code:
$batchupdate = array("valueInputOption" => "RAW", "data" => $dataarray);
try {
$requestBody = new Google_Service_Sheets_BatchUpdateValuesByDataFilterRequest($batchupdate);
$response = $service->spreadsheets_values->BatchUpdateByDataFilter($spreadsheetId, $requestBody);
}
catch(Exception $e) {
echo 'Message: ' . $e->getMessage();
}
Troubleshooting:
Problems with the Request
Until you attach a sanitized version of your Request body we cannot be sure about the root-cause of the problem you are facing.
However, an error 400 means that the request you did is invalid. So, most likely, the problem is in that.
Check if your request object is formatted as detailed on the documentation.
Problems with the Client
If you are able to use the Try this API sidebar with the same Request Body then it could be related to the PHP client.
Note: This is language independent. Create a JSON Object that has the same structure as your request body.
If that's the case, we will need to see more of your code to verify that you are not using your valid Request body in an invalid way (eg. sending it encapsulated in another object).
By referencing the PHP Library documentation you can see the properties of the objects you can use.

eBay inventory API: Get InventoryItems Always return 0 Results

I have a problem about ebay API.
When I call the inventory_item API I get an empty result.
My request is
https://api.ebay.com/sell/inventory/v1/inventory_item?limit=2&offset=0
Response body is:
{
"total": 0,
"size": 0
}
Then I call the inventory_item API By SKU, of course I failed again.
My request is:
https://api.ebay.com/sell/inventory/v1/inventory_item/80003953
(80003953 is my sku in ebay sell platform)
Response body is:
{
"errors": [
{
"errorId": 25710,
"domain": "API_INVENTORY",
"subdomain": "Selling",
"category": "REQUEST",
"message": "We didn't find the entity you are requesting. Please verify the request"
}
]
}
I'm confirm my authorization and sku are correct!
Perhaps you are trying to get items that are created by Ebay-GUI.
This case was already discribed here
So it turns out that eBay's Inventory API is fairly new. Only items created via the Inventory API's can be queried with the Inventory API.
In my case, using the old Trading-API solved the problem.
First, try the getInventoryItems API without limit and offset values.
If the value still returns 0 as count, try to gain new token for the Bearer and double-check with the actual account in the ebay website.
It may be that you are obtaining valid token, but from another account.
Else, try to contact the developers in ebay.
The getInventoryItem (ie first url) call assumes that an item with the given sku exists, while getInventoryItems does not.
It looks like an item with sku 80003953 doesn't exist. You will need to use createOrRemplaceInventoryItem to create a new one.

BadRequest on /metrics REST endpoint in Azure

I'm trying to access the metrics using the Azure Insights API as per the following MSDN blog.
My Request URL is:
https://management.azure.com/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachine/myVM/metrics?api-version=2016-03-30
with proper Accept and Authorization headers.
The same thing works for metricDefinitions and I get back a bunch of MetricDefinitions. But when I try to access the /metrics endpoint, I get back this:
{
"error": {
"code": "BadRequest",
"message": "The request URL is not valid."
}
}
Is there anyway to know what am I doing wrong in the request?
You need to specify the metric's name for any filtering requests. But there is no metric specifed in your URL, which leads to an invalid URL. For example, you want to retreive the CpuTime metric data point, the request url should be like below:
https://management.azure.com/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachine/myVM/metrics?api-version=2016-03-30&$filter=%28name.value%20eq%20%27CpuTime%27%20