Skip to main content

Notifications

Community site session details
Copilot Studio - Topic Creation & Management
Answered

Unable to parse JSON from HTTP request

Like (0) ShareShare
ReportReport
Posted on 21 Nov 2023 13:53:46 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
    5 on 05 May 2024 at 02:58:00
    Re: Unable to parse JSON from HTTP request

    Same issue, tried with above solution. didnt work

  • Verified answer
    GTMRA Profile Picture
    17 on 21 Nov 2023 at 15:55:47
    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
    on 21 Nov 2023 at 15:16:39
    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
    on 21 Nov 2023 at 14:50:30
    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
    17 on 21 Nov 2023 at 14:30:09
    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
    on 21 Nov 2023 at 14:23:58
    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
    17 on 21 Nov 2023 at 14:15:56
    Re: Unable to parse JSON from HTTP request

    how can i share it with you ?

  • HenryJammes Profile Picture
    on 21 Nov 2023 at 14:12:30
    Re: Unable to parse JSON from HTTP request

    Can you share the schema?

    Or the full topic YAML?

  • GTMRA Profile Picture
    17 on 21 Nov 2023 at 14:07:17
    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
    on 21 Nov 2023 at 14:05:31
    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

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,079 Most Valuable Professional

Leaderboard

Featured topics