let body = serde_json::json!({
    "startX": origin_lng,
    "startY": origin_lat,
    "endX": dest_lng,
    "endY": dest_lat,
    "startName": "출발지",
    "endName": "목적지"
});

let response = self.client
    .post(url)
    .header("appKey", &self.api_key)
    .json(&body)
    .send()
    .await?;

So what: ODSay와 달리 GET이 아닌 POST로 좌표로 JSON body에 담아서 보낸다

So why: TMap 보행자 경로 API는 POST 방식이다. ODSAY는 좌표를 쿼리 파라미터로 받지만 TMap은 body로 받는다. 출발지와, 목적지는 TMap API의 필수 파라미터라 빈 값으로 두면 에러가 나므로  비워 놓지 않도록한다

 

+ Recent posts