Browse our guides and interact with our API reference for more information about MEDSAPI DynaMed. Try MEDSAPI DynaMed 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 /user/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. 

 

Code Samples

cURL
# Store multiple article view events.

curl -X POST "https://apis.ebsco.com/medsapi-dynamed/v1/user/article-views"
    -H "authorization: Bearer TOKEN"
    -H "Content-Type: application/json"
    -H "Accept: application/json"
    -d "{\"items\":[{\"article\":{\"id\":\"T116388\",\"section \":{\"title\":\"Overview\"},\"title\":\"Acute Lymphoblastic Leukemia/Lymphoma (ALL)\"},\"eventType\":\"OPEN_ITEM\",\"prevSearchTerm\":\"search:covid\"\",\"timestamp\":\"2020-10-19T19:04:03Z\"}]}"

Java
// Store multiple article view events.

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

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

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

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

// Send the request
Response response = client.newCall(request).execute();

JavaScript
// Store multiple article view events.

const host = "https://apis.ebsco.com";
const path = "/medsapi-dynamed/v1/user/article-views";

// Create the Request
const url = host + path;
const requestBody = {"items":[{"article":{"id":"T116388","section ":{"title":"Overview"},"title":"Acute Lymphoblastic Leukemia/Lymphoma (ALL)"},"eventType":"OPEN_ITEM","prevSearchTerm":"search:covid\"","timestamp":"2020-10-19T19:04:03Z"}]}

const settings = {
    "async": true,
    "crossDomain": true,
    "url": url,
    "method": "POST",
    "headers": {
        "authorization": "Bearer TOKEN",
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
    "processData": false,
    "data": JSON.stringify(requestBody)
};

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

Ruby
# Store multiple article view events.

# Form the URL
urlstr = File.join("https://", "apis.ebsco.com", "/medsapi-dynamed/v1/user/article-views")
url = URI.parse(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::Post.new(url)
request["authorization"] = "Bearer TOKEN"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = {"items":[{"article":{"id":"T116388","section ":{"title":"Overview"},"title":"Acute Lymphoblastic Leukemia/Lymphoma (ALL)"},"eventType":"OPEN_ITEM","prevSearchTerm":"search:covid\"","timestamp":"2020-10-19T19:04:03Z"}]}

# Send the request
response = http.request(request)

Python
# Store multiple article view events.

# Form the URL
url = "/medsapi-dynamed/v1/user/article-views"

# Payload
payload = "{\"items\":[{\"article\":{\"id\":\"T116388\",\"section \":{\"title\":\"Overview\"},\"title\":\"Acute Lymphoblastic Leukemia/Lymphoma (ALL)\"},\"eventType\":\"OPEN_ITEM\",\"prevSearchTerm\":\"search:covid\"\",\"timestamp\":\"2020-10-19T19:04:03Z\"}]}

# Create Connection Instance

conn = http.client.HTTPSConnection("apis.ebsco.com") 

# Create the Request Headers 
headers = { "authorization": "Bearer TOKEN", "Content-Type": "application/json", "Accept": "application/json" } 

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