I am trying to update field of one of my profiles and I am constantly getting:
klaviyo.profile_update('someprofileid')
=> {"errors"=>[{"id"=>"9a6ddf10-414f-4d4e-b455-d743396d97a1", "status"=>403, "code"=>"permission_denied", "title"=>"You do not have permission to perform this action.", "detail"=>"You do not have permission to perform this action.", "source"=>{"pointer"=>"/data/"}}]}
Using classic code sample in ruby:
module Klaviyo
class Api
API_URL = 'https://a.klaviyo.com/api/'
HEADERS = {
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Revision' => '2023-08-15'
}
def initialize
@api_key = ENV['KLAVIYO_KEY']
end
def call_api(http_method, endpoint, payload = nil)
url = URI("#{API_URL}#{endpoint}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
headers = HEADERS.merge('Authorization' => "Klaviyo-API-Key #{@api_key}")
request = http_method.new(url, headers)
request.body = payload.to_json if payload
response = http.request(request)
JSON.parse(response.read_body) if response.read_body.present?
end