Refresh Order Source (Import Orders)
To start seeing orders inside of the Sales Order API, you need to trigger an order source refresh. An order source refresh will reach out to the order source, and import and update your sales orders.
Example
PUT /v-beta/order_sources/:order_source_id/refresh
PUT /v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
{
"order_source_id": "__YOUR_ORDER_SOURCE_ID_HERE__",
"order_source_nickname": "My Shopify account",
"order_source_code": "shopify",
"order_source_friendly_name": "Shopify",
"refresh_info": {
"status": "preparing_update",
"last_refresh_attempt": null,
"refresh_date": "2018-02-10T20:55:46.673Z"
},
"active": true
}
curl -iX PUT https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '{
"order_source_id": "__YOUR_ORDER_SOURCE_ID_HERE__",
"order_source_nickname": "My Shopify account",
"order_source_code": "shopify",
"order_source_friendly_name": "Shopify",
"refresh_info": {
"status": "preparing_update",
"last_refresh_attempt": null,
"refresh_date": "2018-02-10T20:55:46.673Z"
},
"active": true
}'
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "api.shipengine.com")
$headers.Add("API-Key", "__YOUR_API_KEY_HERE__")
$headers.Add("Content-Type", "application/json")
$body = "{`n `"order_source_id`": `"__YOUR_ORDER_SOURCE_ID_HERE__`",`n `"order_source_nickname`": `"My Shopify account`",`n `"order_source_code`": `"shopify`",`n `"order_source_friendly_name`": `"Shopify`",`n `"refresh_info`": {`n `"status`": `"preparing_update`",`n `"last_refresh_attempt`": null,`n `"refresh_date`": `"2018-02-10T20:55:46.673Z`"`n },`n `"active`": true`n}"
$response = Invoke-RestMethod 'https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh' -Method 'PUT' -Headers $headers -Body $body
$response | ConvertTo-Json
var myHeaders = new Headers();
myHeaders.append("Host", "api.shipengine.com");
myHeaders.append("API-Key", "__YOUR_API_KEY_HERE__");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({"order_source_id":"__YOUR_ORDER_SOURCE_ID_HERE__","order_source_nickname":"My Shopify account","order_source_code":"shopify","order_source_friendly_name":"Shopify","refresh_info":{"status":"preparing_update","last_refresh_attempt":null,"refresh_date":"2018-02-10T20:55:46.673Z"},"active":true});
var requestOptions = {
method: 'PUT',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var request = require('request');
var options = {
'method': 'PUT',
'url': 'https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify({"order_source_id":"__YOUR_ORDER_SOURCE_ID_HERE__","order_source_nickname":"My Shopify account","order_source_code":"shopify","order_source_friendly_name":"Shopify","refresh_info":{"status":"preparing_update","last_refresh_attempt":null,"refresh_date":"2018-02-10T20:55:46.673Z"},"active":true})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS =>"{\n \"order_source_id\": \"__YOUR_ORDER_SOURCE_ID_HERE__\",\n \"order_source_nickname\": \"My Shopify account\",\n \"order_source_code\": \"shopify\",\n \"order_source_friendly_name\": \"Shopify\",\n \"refresh_info\": {\n \"status\": \"preparing_update\",\n \"last_refresh_attempt\": null,\n \"refresh_date\": \"2018-02-10T20:55:46.673Z\"\n },\n \"active\": true\n}",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh"
payload = "{\n \"order_source_id\": \"__YOUR_ORDER_SOURCE_ID_HERE__\",\n \"order_source_nickname\": \"My Shopify account\",\n \"order_source_code\": \"shopify\",\n \"order_source_friendly_name\": \"Shopify\",\n \"refresh_info\": {\n \"status\": \"preparing_update\",\n \"last_refresh_attempt\": null,\n \"refresh_date\": \"2018-02-10T20:55:46.673Z\"\n },\n \"active\": true\n}"
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("PUT", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
request.body = "{\n \"order_source_id\": \"__YOUR_ORDER_SOURCE_ID_HERE__\",\n \"order_source_nickname\": \"My Shopify account\",\n \"order_source_code\": \"shopify\",\n \"order_source_friendly_name\": \"Shopify\",\n \"refresh_info\": {\n \"status\": \"preparing_update\",\n \"last_refresh_attempt\": null,\n \"refresh_date\": \"2018-02-10T20:55:46.673Z\"\n },\n \"active\": true\n}"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh");
client.Timeout = -1;
var request = new RestRequest(Method.PUT);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n \"order_source_id\": \"__YOUR_ORDER_SOURCE_ID_HERE__\",\n \"order_source_nickname\": \"My Shopify account\",\n \"order_source_code\": \"shopify\",\n \"order_source_friendly_name\": \"Shopify\",\n \"refresh_info\": {\n \"status\": \"preparing_update\",\n \"last_refresh_attempt\": null,\n \"refresh_date\": \"2018-02-10T20:55:46.673Z\"\n },\n \"active\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"order_source_id\": \"__YOUR_ORDER_SOURCE_ID_HERE__\",\n \"order_source_nickname\": \"My Shopify account\",\n \"order_source_code\": \"shopify\",\n \"order_source_friendly_name\": \"Shopify\",\n \"refresh_info\": {\n \"status\": \"preparing_update\",\n \"last_refresh_attempt\": null,\n \"refresh_date\": \"2018-02-10T20:55:46.673Z\"\n },\n \"active\": true\n}");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh")
.method("PUT", body)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh"
method := "PUT"
payload := strings.NewReader("{\n \"order_source_id\": \"__YOUR_ORDER_SOURCE_ID_HERE__\",\n \"order_source_nickname\": \"My Shopify account\",\n \"order_source_code\": \"shopify\",\n \"order_source_friendly_name\": \"Shopify\",\n \"refresh_info\": {\n \"status\": \"preparing_update\",\n \"last_refresh_attempt\": null,\n \"refresh_date\": \"2018-02-10T20:55:46.673Z\"\n },\n \"active\": true\n}")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "api.shipengine.com")
req.Header.Add("API-Key", "__YOUR_API_KEY_HERE__")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n \"order_source_id\": \"__YOUR_ORDER_SOURCE_ID_HERE__\",\n \"order_source_nickname\": \"My Shopify account\",\n \"order_source_code\": \"shopify\",\n \"order_source_friendly_name\": \"Shopify\",\n \"refresh_info\": {\n \"status\": \"preparing_update\",\n \"last_refresh_attempt\": null,\n \"refresh_date\": \"2018-02-10T20:55:46.673Z\"\n },\n \"active\": true\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"PUT"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "{\n \"order_source_id\": \"__YOUR_ORDER_SOURCE_ID_HERE__\",\n \"order_source_nickname\": \"My Shopify account\",\n \"order_source_code\": \"shopify\",\n \"order_source_friendly_name\": \"Shopify\",\n \"refresh_info\": {\n \"status\": \"preparing_update\",\n \"last_refresh_attempt\": null,\n \"refresh_date\": \"2018-02-10T20:55:46.673Z\"\n },\n \"active\": true\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v-beta/order_sources/__YOUR_ORDER_SOURCE_ID_HERE__/refresh")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "PUT"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
Refresh Info Status
idle
: Order source import is idle; but ready.preparing_update
: An order source refresh has been triggered, and is queued up for a refresh.updating
: The order source is actively refreshing.error
: The last refresh ended with an error, you may re-trigger the refresh to clear the error.