Re: JSON request returning "Access token not specified"

Not applicable

JSON request returning "Access token not specified"

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Text" %>
<%@ Import Namespace="System.Web.UI.Page" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">

    Private Function SendRequest(uri As Uri, jsonDataBytes As Byte(), contentType As String, method As String) As String
        Dim req As WebRequest = WebRequest.Create(uri)
        req.ContentType = contentType
        req.Method = method
        req.ContentLength = jsonDataBytes.Length

        Dim stream = req.GetRequestStream()
        stream.Write(jsonDataBytes, 0, jsonDataBytes.Length)

        Dim response = req.GetResponse().GetResponseStream()

        Dim reader As New StreamReader(response)
        Dim res = reader.ReadToEnd()

        lblCookie.Text = res
        Return res
    End Function
    Sub Page_Load()
        Dim MKTOcookie As String
        If Not Request.Cookies("_mkto_trk") Is Nothing Then
            MKTOcookie = Request.Cookies("_mkto_trk").Value
        End If

        Dim uri As New Uri("")

        Dim accesstkn = "03e39e6a-d902-4f33-XX-XXXXX:XX"
        Dim cookieid = Server.UrlEncode(MKTOcookie)
        Dim fieldsrtn = "email,firstName,lastName,company"
        Dim data = Encoding.UTF8.GetBytes("access_token=" + accesstkn + "&filterType=cookie&filterValues=" + cookieid + "&fields" + fieldsrtn)
        Dim result_post = SendRequest(uri, data, "application/json", "POST")
    End Sub


<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
<asp:Label ID="lblCookie" runat="server"></asp:Label>

Tags (1)
Not applicable

Re: JSON request returning "Access token not specified"

I am guesssing the access token is not being passed as a parameter. Check out the Ruby sample code on the dev docs for this API to see how request should look.