I want to use API to get the available OS list during OSReload.
I found the method SoftLayer_Account::getOperatingSystemReloadImages is mentioned.But cannot find the usage about this method.
Who can help me on this?
Thanks.
I was not able to find this method getOperatingSystemReloadImages. But I found a way to get OS reload options:
First, we need to know the package used to order the server. For example for Virtual Guests, the package used is 46. But if you want to confirm this, please execute the following Rest request:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[vsi_id]/getBillingItem?objectMask=mask[package]
Method: GET
Then, to get ”Reload options”, execute:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Product_Package/46/getItemPrices?objectFilter={ "itemPrices": { "categories": { "categoryCode": { "operation": "os" } } } }&objectMask=mask[id,item[softwareDescription], categories[categoryCode]]
Method: GET
References:
SoftLayer_Virtual_Guest::getBillingItem
SoftLayer_Product_Package::getItemPrices
EDIT:
Now, in order to use ” SoftLayer_Virtual_Guest::reloadOperatingSystem”, we need add some parameters in Json body configuration: “token” and “config” (Ref: SoftLayer_Virtual_Guest::reloadOperatingSystem)
Below is a REST example:
URL:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[virtual_Guest_ID]/reloadOperatingSystem
Method: POST
Json:
{
"parameters": [
"FORCE",
{
"itemPrices": [
{
"id": 45466
}
]
}
]
}
Where: 45466 is the new priceId of the OS
See this example to reload OS https://gist.github.com/softlayer/407058
Related
I have an api link https://apilink.com?_fields=id,name,images which gives me the following format
[
{
"id": 229210,
"name": "Basic Electrical Knowledge",
"images": [
{
"id": 229211,
"date_created": "2023-01-13T18:34:39",
"date_created_gmt": "2023-01-13T07:34:39",
"date_modified": "2023-01-13T18:34:39",
"date_modified_gmt": "2023-01-13T07:34:39",
"src": "https://sampleSite.in/wp-content/uploads/2023/01/SomeUrlSource.jpg",
"name": "Basic Electrical Knowledge",
"alt": ""
}
]
}
]
I want to access only src from images[]. How do I retrieve this from the link. When clicking the link I want to display this:
[
{
"id": 229210,
"name": "Basic Electrical Knowledge",
"src": "https://sampleSite.in/wp-content/uploads/2023/01/SomeUrlSource.jpg"
}
]
How do I do this?
I tried to solve this by providing this parameters:
https://apilink.com?_fields=id,name,images=src
You can achieve this by making a GET request to the API link and then using a library such as JSON.parse() to parse the response and extract the necessary data. After that, you can use a for loop to iterate over the 'images' array in the response and extract the 'src' key from each object in the array. Finally, you can construct a new object with the desired format and return it.
fetch(https://apilink.com?_fields=id,name,images)
.then(response => response.json())
.then(data => {
let newData = []
data.forEach(item => {
let newItem = {
id: item.id,
name: item.name,
src: item.images[0].src
}
newData.push(newItem)
});
return newData;
})
.then(newData => {
console.log(newData);
});
Note that this code snippet is simplified and doesn't handle errors, it's only serve as an example of how you could do it.
Assuming that you can't make server-side changes, implement a little script, and want the result just manipulating the URI the response is no.
The URI is referring to a resource in the server, the _fields seem like a projection to make to the attributes of the desired resource.
In this case, you are trying to make a transformation on the resource given by the server through. If the server does not implement such functionality you must do it by yourself.
You want to transform the attribute images that has type [Object] to a String.
A code snippet like the answered by #RASIKA EKANAYAKA would fit your requirement.
I've been trying to set up a new custom webhook in Zapier, that automatically updates a custom field in JIRA, whenever a specific action occurs. I've followed some tutorials on how to do it, but when I sent the PUT request, it didn't work. I also tested a bunch in postman, but with similar results.
I used this URL:
https://bitsandbirds.atlassian.net/rest/api/3/issue/CYBIRD-1252
Here is my input:
{
"update" : {
"customfield_10051" : "test"
}
}
This is what I got back:
{
"errorMessages": [
"Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token\n at [Source: org.apache.catalina.connector.CoyoteInputStream#498ac517; line: 3, column: 8] (through reference chain: com.atlassian.jira.rest.v2.issue.IssueUpdateBean[\"update\"])"
]
}
Anyone know where I messed up & how to do it right?
fyi here is the view in Zapier
There should be
{
"fields": {
"customfield_10051" : "test"
}
}
I am trying to create checkout url using Admin API with following params.
URL: https://shopy-test11.myshopify.com/admin/api/2020-10/checkouts.json
{
"checkout": {
"line_items": [
{
"variant_id": 37033347711169,"quantity": 2
}
]
}
}
Unfortunately its returning below error which is not properly documented anywhere that I could find.
{
"errors": {
"line_items": {
"0": {
"variant_id": [
{
"code": "invalid",
"message": "is invalid",
"options": {}
}
]
}
}
}
}
I also tried Shopify-api ruby gem and got same error. There are some similar issue online, but none answers why that issue is occurring and how to fix it. This is new app under development which will create custom checkout. There's only one sales channel which is "Online Store" and is enabled for all products. Any ideas how to fix this issue? Any help is appreciated.
You seem to be mixing up concepts here. The checkout API is only associated with the Storefront API, and has nothing to do with the Admin API.
So this URL: /admin/api/2020-10/checkouts.json seems to be impossible. There is no endpoint in the admin API for checkouts, whereas, Storefront API which does have checkouts, might be your proper URL. So try that:
/api/2020-10/checkouts.json
And if you have the correct token in your header, it will likely work.
I have a problem with the aurelia Http Client.
My api (http//localhost:3000/api/posts) works fine. The output of a get call (in postman or in the browser) is:
[
{
"_id": "58a5f4f635c3ab643c74d97a",
"text": "Foo",
"name": "Fooo",
"__v": 0
},
{
"_id": "58a5fcc32586d0683455f78d",
"text": "Bar",
"name": "Baar",
"__v": 0
}
]
This is my get call in the aurelia app:
getPosts(){
return client.get('http//localhost:3000/api/posts','callback')
.then(data => {
console.log(data);
return data.response;
})
}
And this is the output:
As you can see in the image the response contains something with "Aurelia" but my api never touched aurelia so i think there is something wrong with the URL.
Update1:
The fix suggested by GManProgram (missing :) was the problem.
Update2:
I have changed to the client to the aurelia-fetch-client as GManProgram suggested.
Here is the new output
I seems to put the address from the api behind its own address. Ho can I force it only to use the api address?
So first things first, in the example you posted, you are missing the : character after http in the URL.
If that doesn't fix it, and you are using the HttpClient from aurelia-fetch-client, then you may want to try using the .fetch method instead of the .get method
http://aurelia.io/hub.html#/doc/api/aurelia/fetch-client/1.1.0/class/HttpClient
In your case, since it looks like you are expecting json, the typical fetch call would look like:
return this.httpClient.fetch('http://localhost:3000/api/posts')
.then(response => response.json())
.then(response => new CaseModel(response));
Where you can also import the json method from aurelia-fetch-client.
Otherwise, maybe the HttpClient has already been configured in the application with a base URL and it is screwing you up?
What about:
return client.get('posts','callback')
I created private application on my test shop and I am trying to create simple order via the Shopify API following the instructions found here:
http://docs.shopify.com/api/order#create
I am using the last example, and sending POST request to admin/orders.json with this in the body of the request:
{
"order": {
"line_items": [
{
"quantity": 1,
"variant_id": 500775053
}
]
}
}
500775053 is a valid variant id.
The response I'm getting is:
{
"errors": {
"line_items": [
"must have at least one line item"
]
}
}
I don't understand what am I doing wrong? Is there some special parameter that I should pass along the request? Some special header?
Thank you for your help!
Try adding these custom headers:
Content-Type: application/json
Accept: application/json