Browse our guides and interact with our API reference for more information about MEDSAPI Dynamic Health. Try MEDSAPI Dynamic Health and learn about core concepts.

 

 

 

 

Store Article Views Code Samples

Use the code samples below as examples to create an application in your desired language.  The following code samples use the Store Article Views endpoint which allows you to post article views.  Get started and begin to understand the endpoint by following the examples below in the language of your choice. 

 

# Store article views:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'eis-selected-location: 4332920' --header 'authorization: Bearer TOKEN' -d \
'{
  "items": [
    {
     "article": {
         "id": "T116388",
         "title": "Acute Lymphoblastic Leukemia\/Lymphoma (ALL)",
         "section": {
            "title": ""
         }
      },
      "eventType": "OPEN_ITEM",
      "prevSearchTerm": "",
      "timestamp": "2020-10-19T19:04:03Z"
    }
  ]
}' \
'https://apis.ebsco.com/medsapi-dynamic-health/v1/user/store-article-views'
// Store Article Views:

// Construct the client
OkHttpClient client = new OkHttpClient();

// Create the URL
HttpUrl url = new HttpUrl.Builder()
    .scheme("https")
    .host("apis.ebsco.com")
    .addPathSegment("medsapi-dynamic-health")
    .addPathSegment("v1")
    .addPathSegment("user")
    .addPathSegment("store-article-views")
    .build();

// Build the body   
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{
  \"items\": [
    {
     \"article\": {
         \"id\": \"T116388\",
         \"title\": \"Acute Lymphoblastic Leukemia\/Lymphoma (ALL)\",
         \"section\": {
            \"title\": \"\"
         }
      },
      \"eventType\": \"OPEN_ITEM\",
      \"prevSearchTerm\": \"\",
      \"timestamp\": \"2020-10-19T19:04:03Z\"
    }
  ]
}");     

// Build the request
Request request = new Request.Builder()
    .url(url)
    .post(body)
    .addHeader("Accept", "application/json")
    .addHeader("Authorization", "Bearer TOKEN")
    .addHeader("Content-Type", "application/json")
    .addHeader("eis-selected-location", "4332920")
    .build();

// Send the request
Response response = client.newCall(request).execute();
// Store Article Views: 


var host = "https://apis.ebsco.com";
var path = "/medsapi-dynamic-health/v1/user/store-article-views";

// Create the Request
var url = host + path;
var settings = {
  "async": true,
  "crossDomain": true,
  "url": url,
  "method": "POST",
  "processData": false,
  "data": '{
  "items": [
    {
     "article": {
         "id": "T116388",
         "title": "Acute Lymphoblastic Leukemia\/Lymphoma (ALL)",
         "section": {
            "title": ""
         }
      },
      "eventType": "OPEN_ITEM",
      "prevSearchTerm": "",
      "timestamp": "2020-10-19T19:04:03Z"
    }
  ]
}',
  "headers": {
        Accept: "application/json",
        Authorization: "Bearer TOKEN",
        Content-Type: "application/json",
        eis-selected-location: "4332920"
  }  
}

// Send the Request
$.ajax(settings).done(function (response) {
  console.log(response);
});

# Form the URL 
urlstr = File.join('https://', 'apis.ebsco.com', '/medsapi-dynamic-health', '/v1', '/user/article-views')
url = URI(urlstr)

 

# Create the HTTP object
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

 

# Create the request
request = Net::HTTP::Put.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Bearer TOKEN"
request["Content-Type"] = "application/json"
request["x-eis-selected-location"] = "{locationId}"
request.body = '{"items":["article":{"id":"T116388", "title": "Acute Lymphoblastic Leukemia\/Lymphoma (ALL)", "section":{"title":""}],"eventType":"OPEN_ITEM","prevSearchTerm":"", "timiestamp":"2020-10-19T19:04:03Z"}'
 

# Send the request
response = http.request(request)
# Store Article Views:

# Form the URL
url = ''.join(['/medsapi-dynamic-health','/v1', '/user', '/store-article-views'])

# Create Connection Instance
conn = http.client.HTTPSConnection("apis.ebsco.com")

# Payload
payload =  '{"items":["article":{"id":"T116388", "title": "Acute Lymphoblastic Leukemia\/Lymphoma (ALL)", "section":{"title":""}],"eventType":"OPEN_ITEM","prevSearchTerm":"", "timiestamp":"2020-10-19T19:04:03Z"}'
 
# Create the Request Headers
headers = {
    "Authorization": "Bearer TOKEN",
    "Accept": "application/json",
    "Cache-Control": "no-cache",
    "eis-selected-location": "4332920"
    }

# Send Request  
conn.request("POST", url, payload, headers)