Fork me on GitHub
#beginners
<
2016-09-27
>
josh_tackett18:09:21

Is there a way with this library to view the request that is being made?

josh_tackett18:09:33

I am making a request successfully in postman

josh_tackett18:09:42

but the same request with this library isn’t working

josh_tackett19:09:54

must be some difference between how postman works and how the clj-http works

mtkp19:09:33

iirc including :debug true in the options map will print out request information

josh_tackett19:09:30

still having issues

josh_tackett19:09:46

request from postman is working

josh_tackett19:09:52

request from clj-http isn't

josh_tackett19:09:56

requests look the same

josh_tackett19:09:14

{:requestLine
 #<BasicRequestLine GET https://my307174.crm.ondemand.com/sap/c4c/odata/v1/c4codata/ HTTP/1.1>,
 :protocolVersion #<HttpVersion HTTP/1.1>,
 :params
 #<BasicHttpParams org.apache.http.params.BasicHttpParams@69dfb46d>,
 :method "GET",
 :config nil,
 :class org.apache.http.client.methods.HttpGet,
 :allHeaders
 [#<BasicHeader Connection: close>,
  #<BasicHeader Content-Type: application/json>,
  #<BasicHeader x-csrf-token: fetch>,
  #<BasicHeader Authorization: Basic <auth>>,
  #<BasicHeader accept-encoding: gzip, deflate>],
 :aborted false,
 :URI
 #<URI https://my307174.crm.ondemand.com/sap/c4c/odata/v1/c4codata/>}

josh_tackett19:09:31

GET /sap/c4c/odata/v1/c4codata/ HTTP/1.1
Host: 
Authorization: Basic <auth>
x-csrf-token: fetch
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: cdfe98fa-9145-011c-35f1-231586fa4892

josh_tackett19:09:38

first is clj, second is postman

mtkp19:09:52

whats the response for clj http?

josh_tackett19:09:13

it is success, but then when I use the token to make a write request I get a 403

mtkp19:09:26

so GETs work fine but POST/PUT does not?

josh_tackett19:09:45

no the GET is getting the wrong token

josh_tackett19:09:52

it gets a token, but that token doesn’t work

josh_tackett19:09:57

even with a postman POST request

mtkp19:09:28

perhaps no-cache matters?

josh_tackett19:09:42

I added that also 😕

mtkp19:09:13

hmm. nothing else stands out to me 😕

mtkp19:09:29

what does the clj-http function call look like?

josh_tackett19:09:08

@mtkp

(http/request
         {:method :get
          :url ""
          :headers {"Authorization" (str "Basic " (base64/encode “<user>:<pass>"))
                    "x-csrf-token" "fetch"
                    "Content-Type" "application/json"
                    "Cache-Control" "no-cache"}
          :debug true
          })

adrien20:09:21

hello I'm having a hard time establishing a websocket connection in clojurescript (please let me know if I should post this in the clojurescript channel, though I think it's a trivial mistake) here's the code:

(defonce ws-chan (atom nil))

(defn connect! []
  (let [ws (js/WebSocket. ws-url)]
    (do
      (reset! ws-chan ws)
      (loop []
        (when (= (.-readyState @ws-chan) 1)
          (.log js/console (str "readystate " (.-readyState @ws-chan)))
          (recur))))))

adrien20:09:47

ws-url is a defined constant

adrien20:09:34

nothing gets printed