2

I am trying to work with sears api and my process is failing due to my lack of understanding the documentation provided by sears

this is the sears url

https://www.searscommerceservices.com/question/seller-facing-api-changes-0216/

based upon what they have given as to how to generate the signature and authenticate i am trying something like this but i am getting an error:

Request Timed out

Here is my Try in CF

<cfscript>
        function ISODateFormat(datetime) {
        return '#DateFormat(datetime, "yyyy-mm-dd")#T#TimeFormat(datetime, "HH:mm:ss")#Z';
    }
    </cfscript>
    <cfset variables.sellerid = '1234'>
    <cfset variables.emailaddress = 'abc@domain.com'>
    <cfset variables.secretkey = 'xxxx='>
    <cffunction name="auth" access="public" returntype="any">
        <cfset var myResult="">
        <cfset sDate = ISODateFormat(now())>
        <cfset StrtoSig = "#variables.sellerid#:#variables.emailaddress#:#sDate#">
        <cfset secretKey = variables.secretkey>
        <cfset x = hmac("#StrtoSig#","#secretKey#","HMACSHA256","utf-8")> 
        <cfreturn x>
    </cffunction>

    <cffunction access="public" name="getitems" returntype="any">
        <cfset surl = 'https://seller.marketplace.sears.com/SellerPortal/api/attributes/v4?itemClassId=1234&sellerId=1234'>
        <cfset getauth = auth()>
        <cfset sheader = "authorization:HMAC-SHA256 emailaddress=#variables.emailaddress#,timestamp=#sDate#,signature=#getauth#">
        <cfhttp url="#surl#" result="results">
            <cfhttpparam name="authorization" type="HEADER" value="#sheader#">
        </cfhttp>
        <cfdump var="#results#">
    </cffunction>
Avin
  • 69
  • 1
  • 1
  • 7
  • Because you get a request time out and not a api error, do you have the certificate installed? https://stackoverflow.com/a/20475763/5303755 – Brendan Doherty Jul 31 '17 at 12:57
  • did not installed any certificate and sears api does not mention anything like that – Avin Aug 01 '17 at 03:40
  • What timezone is your server running in? Check the date set in your ISODateFormat(Now()) as that will return your server's current timestamp which may not be UTC? – Phipps73 Aug 02 '17 at 10:16
  • i am with hostek.com so i assume its EST – Avin Aug 02 '17 at 14:43
  • So EST is 5 hours behind UTC therefore your timestamp is outside of the 30 minute time limit that the API expects. – Phipps73 Aug 02 '17 at 14:45

0 Answers0