Skip to main content

Notifications

Topic Creation & Management
Answered

Unable to parse JSON from HTTP request

Posted on by 17

Hello,

 

using a HTTP request that returns a simple JSON string. Regardless of how I tried to return the JSON i am always getting the following message :

 

Error Message: The provided value for path ‘Topic.Var1’ cannot be parsed into ‘RecordDataType’ type. Provided value: “{”“msg”“:”“Welcome, how can i help you ?”“,”“name”“:”“”“,”“timestamp”“:1700574123}” Error Code: ValueParsingError Conversation Id: 0b50d6ad-54f9-4884-9823-04a737136450 Time (UTC): 2023-11-21T13:42:03.078Z

 

For simplicity, The JSON response does not require any headers and/or body data to be returned, it is always returned on every request.

 

This is the JSON string :

 

{"msg":"Welcome, how can i help you ?","name":"alexggg","timestamp":1700574256}

 

What do I need to adjust in order to make this work ? 

 

Thank you for your help.

 

 

Annotation 2023-11-20 140728.png

  • HimanshuKat Profile Picture
    HimanshuKat 2 on at
    Re: Unable to parse JSON from HTTP request

    Same issue, tried with above solution. didnt work

  • Verified answer
    GTMRA Profile Picture
    GTMRA 17 on at
    Re: Unable to parse JSON from HTTP request

    Thank you for your help. The headers were incorrect and needed to be set to :

     

    Content-Type: application/json; charset=utf8

     

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Unable to parse JSON from HTTP request

    Thanks @GTMRA 

     

    I think you get this error because your API returns your JSON as text/html; charset=utf-8 and not as JSON (I was initially puzzled in Postman as it wouldn't format the content nicely).

     

    To work around this, you can switch to the code editor view and update your HTTP request node to set the responseSchema to Any

     

    HenryJammes_0-1700579685052.png

     

    You can then parse it with the desired schema in a subsequent Parse value node:

     

    HenryJammes_1-1700579711173.png

     

    HenryJammes_2-1700579720676.png

    And it now works:

     

    HenryJammes_4-1700579746208.png

     

     

    HenryJammes_3-1700579738093.png

     

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Unable to parse JSON from HTTP request

    I can't repro, I guess because I don't have access to the API.

    Error Message: HTTP request failed with status code 403 Forbidden. Error Code: HttpRequestFailure Conversation Id: ba2ff1c9-382c-4939-ac82-91bb35f20b8b Time (UTC): 2023-11-21T14:36:37.860Z

     

    Are you use the API returns a clean JSON? What does the GET request look like when you open https://chatapp.azurewebsites.net/chat.php in your browser or in Postman?

  • GTMRA Profile Picture
    GTMRA 17 on at
    Re: Unable to parse JSON from HTTP request

    here is the YAML file.

    kind: AdaptiveDialog
    beginDialog:
     kind: OnConversationStart
     id: main
     actions:
     - kind: SendActivity
     id: sendActivity_xPPdyN
     activity: Hello, I'm {System.Bot.Name}. I am a virtual agent.
    
     - kind: Question
     id: question_WRJgdJ
     interruptionPolicy:
     allowInterruption: true
    
     variable: init:Global.PersonName
     prompt: What is your name ?
     entity: PersonNamePrebuiltEntity
    
     - kind: Question
     id: question_8mECkK
     interruptionPolicy:
     allowInterruption: true
    
     variable: init:Global.WhatToDo
     prompt: |-
     Welcome to the chat, {Global.PersonName}.
     
     What would you like to do?
     entity:
     kind: EmbeddedEntity
     definition:
     kind: ClosedListEntity
     items:
     - id: Chat with an agent
     displayName: Chat with an agent
    
     - id: Book an appointment
     displayName: Book an appointment
    
     - id: JSON
     displayName: JSON
    
     - kind: ConditionGroup
     id: conditionGroup_YSBOAU
     conditions:
     - id: conditionItem_KTHAdC
     condition: =Global.WhatToDo = 'cr437_testBot.topic.ConversationStart.main.question_8mECkK'.'Chat with an agent'
     actions:
     - kind: SendActivity
     id: sendActivity_7gMyb9
     activity: " Connecting you with an agent {Global.PersonName}, please hold on..."
    
     - kind: TransferConversationV2
     id: lyokrx
     transferType:
     kind: TransferToAgent
     messageToAgent: test
    
     - id: conditionItem_zx15MA
     condition: =Global.WhatToDo = 'cr437_testBot.topic.ConversationStart.main.question_8mECkK'.'Book an appointment'
     actions:
     - kind: SendActivity
     id: sendActivity_nACezM
     activity: link to book an appointment
    
     - id: conditionItem_qe25v3
     condition: =Global.WhatToDo = 'cr437_testBot.topic.ConversationStart.main.question_8mECkK'.JSON
     actions:
     - kind: HttpRequestAction
     id: xg1CKA
     url: https://chatapp.azurewebsites.net/chat.php
     response: Topic.Var1
     responseSchema:
     kind: Record
     properties:
     msg: String
     name: String
     timestamp: Number
    
     - kind: SendActivity
     id: sendActivity_BAtywk
     activity: response
  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Unable to parse JSON from HTTP request

    Can you paste it here or send it as attachment, perhaps over private message?

  • GTMRA Profile Picture
    GTMRA 17 on at
    Re: Unable to parse JSON from HTTP request

    how can i share it with you ?

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Unable to parse JSON from HTTP request

    Can you share the schema?

    Or the full topic YAML?

  • GTMRA Profile Picture
    GTMRA 17 on at
    Re: Unable to parse JSON from HTTP request

    Thanks for the reply, thats how i already configured the response, via the sample data.

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Unable to parse JSON from HTTP request

    Did you edit the schema?

     

    You can do that easily by selecting "From sample data" in "Response data type" :

    HenryJammes_0-1700575461305.png

    Pasting the JSON here:

    HenryJammes_1-1700575492416.png

    Will generate the following schema:

    HenryJammes_2-1700575510881.png

     

     

     

     

Helpful resources

Quick Links

Exciting News for Copilot Studio Communi…

Get ready to experience a whole new level of engagement with the Copilot Studio…

Celebrating the May Super User of the…

LaurensM is an exceptional contributor to the Power Platform Community…

Check out the Copilot Studio Cookbook…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 137,998

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,059

Leaderboard

Featured topics