자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다. 
  • 제품설치/등록 오류 문의: 설치/등록 Q&A 이용 (제품 구매 고객 한정)

Delphi Rest Api 질문입니다.

2020.01.22 20:12

희망나라 조회 수:1039

본 게시판은 개발자들이 자유롭게 질문과 답변을 공유하는 게시판입니다.
* 따라서 최대한 정중하게 질문을 올려 주세요.
* 질문을 상세히 작성해 주실 수록 좋은 답변이 올라 옵니다.
* 다른 분들도 참고할 수 있도록 결과 댓글 필수(또는 감사 댓글)
(결과 댓글을 달지 않는 경우 다음 질문에 대한 답변이 달리지 않는 불이익이 있을 수 있습니다.)
-----------------------------------------------------------------------------------------------

Xe8 Vcl 로 개발중입니다.

네이버 Rest Api 중 쇼핑 API 을 json 으로 호출 합니다..


procedure TForm1.GetNaverShop(AGubun:string);
var
  Param: TRESTRequestParameter;
  Url, token: string;
  Stream: TMemoryStream;
  JSONResponse : TJSONObject;   //use System.JSON
  jValue       : TJSONValue;    // use System.JSON
begin
  Memo1.Lines.Clear;

  RESTClient1.BaseURL := 'https://openapi.naver.com';
  RESTClient1.Accept := '*/*';
  RESTClient1.AcceptCharset := 'UTF-8';
  RESTClient1.UserAgent := 'curl/7.49.1';

  RESTRequest1.Client := RESTClient1;
  RESTRequest1.Response := RESTResponse1;
  RESTRequest1.Method := rmGET;

  RESTRequest1.Resource := '/v1/search/shop.json?query={query}&display=10&start=1&sort=sim';
  RESTRequest1.Params.ParameterByName('query').Value := EDdescr.Text;

  Param := RESTRequest1.Params.AddHeader('X-Naver-Client-Id', 'myid');
  Param := RESTRequest1.Params.AddHeader('X-Naver-Client-Secret', 'my secret');
  Param.Options := [TRESTRequestParameterOption.poDoNotEncode];

  RESTRequest1.Execute;

  Memo1.Lines.Text := RESTResponse1.Content;

 

-------Execute-----하고 나면  아래 ---결과 파일-- 이 만들어 집니다.

 

  try
    Url := RESTResponse1.JSONValue.GetValue<String>('image'); //----(1)이부분에서 에러 발생
  Except
    On E:Exception do begin
      Memo1.lines.Add(e.Message);
      Exit;
    end;
  end;

  RESTClient2.BaseURL := Url;
  RESTRequest2.ExecuteAsync(procedure
    begin
      Stream := TMemoryStream.Create;
      try
        Stream.WriteData(RESTResponse2.RawBytes, RESTResponse2.ContentLength);
        //ImageControl1.Bitmap.LoadFromStream(Stream);
        Image1.Picture.Bitmap.LoadFromStream(Stream);// (2)
      finally
        Stream.Free;
      end;
    end
  );
  end;

 

질문)

(1)에서 에러 발생원인이 "image" 의 "" 와 관련이 있는건가요.?

(2)VCL에서 사용하기 위해 Image1 사용함 

 

감사합니다.

 

 

---결과 파일--

{
"lastBuildDate": "Wed, 22 Jan 2020 19:53:28 +0900",
"total": 1808,
"start": 1,
"display": 10,
"items": [
{
"title": "농심 <b>새우깡 400g</b>",
"link": "https://search.shopping.naver.com/gate.nhn?id=6725761862",
"image": "https://shopping-phinf.pstatic.net/main_6725761/6725761862.20191231185207.jpg",
"lprice": "2980",
"hprice": "70810",
"mallName": "네이버",
"productId": "6725761862",
"productType": "1"

},
{
"title": "농심 대용량 스낵 (지퍼백) <b>새우깡</b> 포스틱 꿀꽈배기 자갈치 오징어집 조청유과 감자깡",
"link": "https://search.shopping.naver.com/gate.nhn?id=82263818665",
"image": "https://shopping-phinf.pstatic.net/main_8226381/82263818665.3.jpg",
"lprice": "2850",
"hprice": "0",
"mallName": "농심공식몰",
"productId": "82263818665",
"productType": "2"

},
{
"title": "농심 매운 <b>새우깡 400g</b>",
"link": "https://search.shopping.naver.com/gate.nhn?id=8588558030",
"image": "https://shopping-phinf.pstatic.net/main_8588558/8588558030.20150622134018.jpg",
"lprice": "3090",
"hprice": "37740",
"mallName": "네이버",
"productId": "8588558030",
"productType": "1"

},
{
"title": "농심 매운<b>새우깡400g</b> 과자 봉지과자 스낵",
"link": "https://search.shopping.naver.com/gate.nhn?id=18674959336",
"image": "https://shopping-phinf.pstatic.net/main_1867495/18674959336.1.jpg",
"lprice": "3990",
"hprice": "0",
"mallName": "쿠팡",
"productId": "18674959336",
"productType": "2"

},
{
"title": "농심 <b>새우깡400g</b> 농심 새우깡 매운 <b>새우깡 400g</b> 노래방 대용량과자",
"link": "https://search.shopping.naver.com/gate.nhn?id=21667660865",
"image": "https://shopping-phinf.pstatic.net/main_2166766/21667660865.jpg",
"lprice": "2980",
"hprice": "0",
"mallName": "티몬",
"productId": "21667660865",
"productType": "2"

},
{
"title": "농심 새우깡 매운 <b>새우깡 400g</b> 노래방 대용량과자",
"link": "https://search.shopping.naver.com/gate.nhn?id=80132527240",
"image": "https://shopping-phinf.pstatic.net/main_8013252/80132527240.1.jpg",
"lprice": "3000",
"hprice": "0",
"mallName": "빅카트",
"productId": "80132527240",
"productType": "2"

},
{
"title": "농심 <b>새우깡 400G</b>",
"link": "https://search.shopping.naver.com/gate.nhn?id=7789394589",
"image": "https://shopping-phinf.pstatic.net/main_7789394/7789394589.jpg",
"lprice": "4100",
"hprice": "0",
"mallName": "롯데프레시",
"productId": "7789394589",
"productType": "2"

},
{
"title": "농심 <b>새우깡 400g</b>",
"link": "https://search.shopping.naver.com/gate.nhn?id=5743436445",
"image": "https://shopping-phinf.pstatic.net/main_5743436/5743436445.20191231184909.jpg",
"lprice": "3500",
"hprice": "29940",
"mallName": "네이버",
"productId": "5743436445",
"productType": "1"

},
{
"title": "(농심) 노래방 <b>새우깡 400G</b> X 6개 1박스",
"link": "https://search.shopping.naver.com/gate.nhn?id=11450498354",
"image": "https://shopping-phinf.pstatic.net/main_1145049/11450498354.1.jpg",
"lprice": "19300",
"hprice": "0",
"mallName": "대진물류",
"productId": "11450498354",
"productType": "2"

},
{
"title": "대용량 스낵 8종 골라담기 <b>새우깡400g</b> 외",
"link": "https://search.shopping.naver.com/gate.nhn?id=21606646713",
"image": "https://shopping-phinf.pstatic.net/main_2160664/21606646713.jpg",
"lprice": "2720",
"hprice": "0",
"mallName": "인터파크",
"productId": "21606646713",
"productType": "2"

}
]
}
 

번호 제목 글쓴이 날짜 조회 수
공지 [프로그래밍 강의] 2021.6~2021.12 관리자 2015.01.22 15767
공지 유용한 관련 사이트 관리자2 2014.03.20 54580
공지 본 게시판은 개발자 여러분들의 질문과 답변을 공유하는 공간입니다. 관리자 2012.01.10 97985
839 Appmethod 에 TMS 콤포넌트 설치가 안되나요? [1] 농가사랑 2014.12.15 999
838 시리얼통신 델파이 -> 안드로이드 시리널통신 도와주세요 [2] 텔로스김 2017.09.22 1005
837 BroadcastReceiver 는 어떻게 구현해야 하나요? [1] goms 2015.01.27 1005
836 안녕하세요 현재 고2 논문작성하는데 개발자 소스코드+조언 부탁드려도될까요 ㅠㅠ [2] 브루스너구링 2018.07.22 1007
835 Incompatible type 에러 [2] gent 2018.11.14 1007
834 겔4안드로이드에서XE7연결방법좀 알려주세요? [3] 모나도 2014.12.31 1007
833 (공유) RAD 스튜디오 10.3.3에서 VCL에서 ImeMode를 imHanguel로 설정 시 자간(글자간격)이 늘어납니다. file 험프리 2020.03.24 1008
832 [XE7] 파이어몽키 프로젝트 생성 시 "No platform available current project" 메시지 발생 Humphery 2015.01.15 1008
831 안드로이드 다국어 가상 키보드 고정 방법 있나요? [2] 한사람 2016.04.15 1009
830 IDFTP.List 한글 깨짐에 대한 답변 관련해서 .... [1] jcitec 2015.05.16 1011
829 [에러] ISO C++17 does not allow 'register' storage class specifier [2] file lamp 2019.11.29 1013
828 비콘 관련 문의드려요 ^^;;; [4] 쭈녕 2015.11.29 1018
827 시애틀버전 아이폰 앱등록시 IPV6 지원문제 [4] 사랑남 2016.07.29 1019
826 IdHTTP 이용시 한글 깨짐현상 file 브로아 2018.05.01 1019
825 [XE3] FireDAC Query 문제입니다.. [3] 술그머니홍구 2015.01.06 1019
824 Android permission 루트 data 폴더 접근권한 얻으려면? [2] 델마당쇠 2020.08.31 1023
823 조금..난해한 질문입니다만...앱개발 테스트 방법에 관한 질문입니다. [2] 준식 2015.01.09 1026
822 google maps api 질문이요 ! [1] nickname 2016.09.03 1027
821 FastReport 5 설치방법 [1] 스카이 2018.07.12 1029
» Rest Api 질문입니다. [3] 희망나라 2020.01.22 1039