자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다. 
  • 제품설치/등록 오류 문의: 설치/등록 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 54581
공지 본 게시판은 개발자 여러분들의 질문과 답변을 공유하는 공간입니다. 관리자 2012.01.10 97988
493 브레이크 포인트 무작동 [3] file 젠틀 2019.05.07 997
492 xe 10.3 에서 lib path 연결 하는 방법은 무엇인지요? [2] 김태현 2018.12.26 998
491 (공유) RAD 스튜디오 10.3.3에서 VCL에서 ImeMode를 imHanguel로 설정 시 자간(글자간격)이 늘어납니다. file 험프리 2020.03.24 1008
490 [XE7] 파이어몽키 프로젝트 생성 시 "No platform available current project" 메시지 발생 Humphery 2015.01.15 1008
489 Incompatible type 에러 [2] gent 2018.11.14 1009
488 IDFTP.List 한글 깨짐에 대한 답변 관련해서 .... [1] jcitec 2015.05.16 1013
487 시애틀버전 아이폰 앱등록시 IPV6 지원문제 [4] 사랑남 2016.07.29 1019
486 IdHTTP 이용시 한글 깨짐현상 file 브로아 2018.05.01 1019
485 [XE3] FireDAC Query 문제입니다.. [3] 술그머니홍구 2015.01.06 1019
484 조금..난해한 질문입니다만...앱개발 테스트 방법에 관한 질문입니다. [2] 준식 2015.01.09 1026
483 google maps api 질문이요 ! [1] nickname 2016.09.03 1027
482 FastReport 5 설치방법 [1] 스카이 2018.07.12 1029
» Rest Api 질문입니다. [3] 희망나라 2020.01.22 1039
480 [10.4 시드니 신기능] 10.4 시드니와 10.3 리오를 같이 설치해도 되나요? 험프리 2020.06.10 1039
479 Multi Language 적용 관련하여 질문 드립니다. [1] 앰버 2014.12.09 1047
478 앱아이콘과 앱이 실행될때 이미지 변경은 어떻게 하는건가요? [4] file kim 2015.12.01 1048
477 다시 문의 xe7 ios 빌드 중 에러 발생건 문의 [3] file 사랑남 2015.01.10 1051
476 Disconnected session [1] file 우린굉장해 2020.05.15 1052
475 스마트폰을 비콘으로 사용하는 샘플이나 예는 있는지 [2] 화이부동 2016.08.04 1057
474 [마이그레이션][팁] 텍스트에디터를 이용해 컴포넌트 속성 추가 및 수정 일괄 처리하기 [1] file 험프리 2018.04.18 1058