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

Delphi Rest Api 질문입니다.

2020.01.22 20:12

희망나라 조회 수:1036

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

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 15762
공지 유용한 관련 사이트 관리자2 2014.03.20 54577
공지 본 게시판은 개발자 여러분들의 질문과 답변을 공유하는 공간입니다. 관리자 2012.01.10 97974
2739 "Ignore this exception type" 다시 활성화 방법문의 드립니다. [1] file 슈크림 2020.01.31 747
2738 안드로이드 calendar에 요일 밑에 text 추가 할수 있나요? [1] 델마당쇠 2020.01.28 1716
2737 델파이로 iso앱을 개발하려면 mac pc가 있어야 하나요? [1] 델마당쇠 2020.01.24 192
2736 system.pas 에러 해결방법은 무엇인가요? [1] 날라리아 2020.01.28 2720
» Rest Api 질문입니다. [3] 희망나라 2020.01.22 1036
2734 RX Currency Edit 콤포넌트를 대체할 대안이 있을까요? 날라리아 2020.01.28 205
2733 '완료' 버튼의 키 값이 궁금합니다. [3] file 푸른솔 2020.01.14 862
2732 datasnap 세션유지 또는 재연결 [2] 델마당쇠 2020.01.14 406
2731 소스코드 편집 창에서 블럭 선택 오류 [2] 오랜동안 2018.02.26 297
2730 클릭, 더블클릭 구분하는방법이 있을까요?? [1] Danny 2020.01.15 1107
2729 ADO Query를 사용시 시간 걸리는 문제의 건 한태수 2020.01.14 303
2728 VCL 폼스타일 변경시 TrackBar의 SelEnd 색상표시가 궁금합니다. file OJTO 2020.01.14 156
2727 델파이 오토컴플릿 [2] pky4437 2020.01.08 319
2726 dbexconnections.ini 파일 에러 [2] 그래요 2020.01.08 193
2725 ClientDataSet 이 연결오류 [1] file 우기여니아빠 2019.11.29 251
2724 리치에디텅에 관해서 질문잇습니다 [2] 헨씀히포 2020.01.04 4158
2723 안드로이드 ListView item background color 변경 하려면? [1] 델마당쇠 2020.01.03 569
2722 그룹박스 Paint관련 [2] 크림슨킹 2020.01.05 7440
2721 모바일에로 디버깅 또는 릴리즈 버전으로 컴파일 할 경우 [2] file 종결자 2020.01.02 167
2720 앱아이콘과 앱이 실행될때 이미지 변경은 어떻게 하는건가요? [4] file kim 2015.12.01 1047