자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다. 
  • 제품설치/등록 오류 문의: 설치/등록 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
1753 FireDAC MS SQL Table 접속 문의 [1] 아들만셋 2020.02.03 1211
1752 Form의 BorderStyle 정의시점?에 대한 차이점 질문입니다. [5] file Danny 2020.01.22 220
1751 MDI Child Dll [2] 라시드 2015.10.26 351
1750 StringGrid에 출력되는 Data(제목등)이 이중(잔상?)으로 나오는데 해결책을 구합니다. [4] file AllwaysHappy 2017.11.01 13851
1749 델파이 10.3.3 Rio 에서 fastreport 가 어디 있나요? [1] 노력하는삶 2020.02.04 159
1748 Windows 64-bit로 빌드 후 실행 시 오류가 납니다. [1] file 비앤케이 2020.02.03 231
1747 델파이 컴파일 후 실행 오류 관련 [2] file 똘귀아빠 2020.01.31 231
1746 [현대화 세미나] 윈도우, 우분투, 안드로이드, iOS, OSX 간 효과적인 마이그레이션 방법이 궁금합니다. 험프리 2020.01.31 294
1745 [현대화 세미나] 리눅스 환경에서 데이터스냅 배포 방법이 궁금합니다. 험프리 2020.01.31 237
1744 원격서버(호스팅서버)에 데이터스냅 미들웨어 배포하는 방법 운직 2020.01.31 100
1743 DB접속에 문제가 있어 여쭈어 봅니다. [5] 루키 2019.08.07 596
1742 "Ignore this exception type" 다시 활성화 방법문의 드립니다. [1] file 슈크림 2020.01.31 748
1741 안드로이드 calendar에 요일 밑에 text 추가 할수 있나요? [1] 델마당쇠 2020.01.28 1716
1740 델파이로 iso앱을 개발하려면 mac pc가 있어야 하나요? [1] 델마당쇠 2020.01.24 192
1739 system.pas 에러 해결방법은 무엇인가요? [1] 날라리아 2020.01.28 2723
» Rest Api 질문입니다. [3] 희망나라 2020.01.22 1039
1737 RX Currency Edit 콤포넌트를 대체할 대안이 있을까요? 날라리아 2020.01.28 205
1736 datasnap 세션유지 또는 재연결 [2] 델마당쇠 2020.01.14 408
1735 소스코드 편집 창에서 블럭 선택 오류 [2] 오랜동안 2018.02.26 297
1734 클릭, 더블클릭 구분하는방법이 있을까요?? [1] Danny 2020.01.15 1107